Converting the Windows Script Host CreateObject Method
Definition: Creates a COM object.
To create a COM object using Windows PowerShell all you have to do is call the New-Object cmdlet, taking care to precede the application’s ProgID with the –com parameter. For example, this command creates an instance of Microsoft Excel (Excel.Application), and then sets the Visible property to True, enabling you to view that instance of Excel onscreen:
$a = New-Object -com Excel.Application $a.Visible = $True
As you can see, there’s no need to enclose the ProgID in quotation marks. But what if you’re a long-time VBScript scripter and you’re used to enclosing ProgIDs in quotation marls? Well, here’s an idea: go ahead and enclose the ProgID in quotation marks. This block of code will also create a running instance of Microsoft Excel that you can see onscreen:
$a = New-Object -com "Excel.Application" $a.Visible = $True