PowerShell: SMS 2003 / ConfigMgr 2007 scripting
I decided it was about time I learned more PowerShell and SMS 2003 / SCCM 2007 scripting. I hope you enjoy this series, as I fail, experiment, and learn nuances of the PowerShell language.
There seem to be a lot of information about 3 ComObjects for SMS 2003 / SCCM 2007 on the internet. Those are:
How do I use a COM Object in PowerShell?
- Create an Object
- Declare the type of Object
- Set Source
You do this by the keyword “New-Object”
BTW, you can get help by using “Get-Help”
PS C:\ > Get-Help New-Object
This will return useful information about New-Object. The parameter we are interested in is:
-comObject <string>
Programmatic Identifier (ProgID) of the COM object.
Next important thing to know is how to declare a variable. You put a $ sign infront of a string. That’s it.
Here is how you would connect to each of the following COM objects.
PS C:\> New-Object -ComObject Microsoft.SMS.Client
PS C:\> New-Object -ComObject cpapplet.cpappletmgr
PS C:\> New-Object -ComObject UIResource.UIResourceMgr
Note running any of the following above will return a blank line. Nothing more. Why? Because you didn’t do anything with the COM, you opened a connection, then closed it. Clean.
How do I do something with it?
Try this post: PowerShell: How do I connect to SMS 2003 and perform Client Actions?
Try this post: PowerShell: How do I trigger SMS 2003 Inventory Actions?
More to come.