Use a COM Object
Problem
You want to create a COM object to interact with its methods and properties.
Solution
Use the NewObject cmdlet (with the –ComObject parameter) to create a COM object from its ProgID. You can then interact with the methods and properties of the COM object as you would any other object in PowerShell.
$object = NewObject ComObject ProgId
For example:
PS >$sapi = NewObject Com Sapi.SpVoice PS >$sapi.Speak("Hello World")
Discussion
- Read more about Use a COM Object
- Log in or register to post comments