Grab our RSS feeds Follow us on Twitter Join our Facebook Group Connect with us on LinkedIn
myITforum.com, Powered by You.
you are not logged in

Articles

Newslinks

Links

Downloads

Site Services

Community Forums

Discussion Lists

Article Search

Newsletter

Web Blogs

FAQs

Live Support

myITforum TV

Take a Poll

Monthly Drawing

myITforum Network

User Group Directory

Our Partners

About Us

Register

Login

BRONZE PARTNER:

BRONZE PARTNER:



Industry News:




  Home : Articles : Windows PowerShell print | email | | Forums |   print | email | | Blogs |   print | email | | Wiki |   print | email | | FAQs |   print | email | Article Search  
PowerShell: SMS 2003 / ConfigMgr 2007 scripting


Bookmark and Share

By: Shaun Cassells
Posted On: 10/13/2008

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:

SMS Client Actions
Microsoft.SMS.Client
Control Panel
Client Actions
cpapplet.cpappletmgr
Software Distribution
UIResource.UIResourceMgr

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.


  myITforum.com ©2010 | Legal | Privacy