As is the case with WMI and XML, PowerShell also supports working with the COM type of objects. In this section, we will understand how COM works in PowerShell using two interesting examples that cover COM with Internet Explorer and Microsoft Excel.
In order to create an instance of a COM object, we use the
New-Object cmdlet with the
-ComObject parameter and
ProgID as an argument, where the
ProgID is the friendly name of the COM class used during class registration. Thus, the final command should look like this:
#create new COM object PS C:\> $com = New-Object –ComObject <ProgID>
As mentioned earlier, the
ProgID parameter is required to create ...