Open MS Word, create a COM object "Word.Application" and store the resulting reference in a variable:
SpVoice has the advantage of allowing you to install and use additional voices. System.Speech.* is the "official" support for speech in the. PS C:\> $voice.speak("SS64 taught me everything") PS C:\> $voice = new-object -ComObject "SAPI.SPVoice" Speak a sentence using Microsoft Speech SpVoice Interface API: PS C:\> Add-Type -AssemblyName System.Speech # Then instantiate and display an object based on this class: However it is faster to just directly cast it:Īn alternative is to create this using a type-safe template class: $myObject = New-Object -TypeName PSObject -Property $myHashtable If you already have a hash table, it can be converted into a custom Object using the -TypeName of PSObject: Custom objects (PSCustomObject)Ī simple custom object of type PSCustomObject can be created using a hash table: $gyro = "Gyroscope"Ī PSCustomObject will accept any data type, you can create something as or but then still update it later to a string value. Net or COM object, PowerShell also allows you to create custom objects for your own collections of data items.
The New-Object cmdlet allows you to create a new instance of a. This enables you to distinguish actual COM objects from Raise an error if the COM object that you attempt to If the object is not a PSObject, the command generates a non-terminating error. If the new object is derived from the PSObject class, a property is specified thatĭoes not exist on the object, it will be added to the object as a NoteProperty. Sets each property value and invokes each method in the order that they appear in the hash table. The values are property values or method arguments.
Set property values and invokes methods of the new object.Įnter a hash table in which the keys are the names of properties or methods and
Programmatic Identifier (ProgID) of the COM object. New-Object string Object]Ī comma separated list of arguments to pass to the constructor of the. This allows you to startup and control other applications (including VBScript) from PowerShell.