There are other good resources like HeyScriptingGuy's blog where one can serach for WMI tag, there is whole bunch of information out there on leveraging WMI with PowerShell. If you haven't checked out this yet then you are missing something very cool to manage your Infrastructure.
That being mentioned the journey to exploring WMI starts by connecting to the SCCM Site System which has the SMS provider installed.
Open the ConfigMgr console > Connect to your Central Site/Primary Site > Site Management > Right -click site ...select Properties. The information where SMS provider ins installed can be fetched by site properties general tab in ConfigMgr MMC
After getting the Server having SMS provider installed, we are going to explore the SMS provider a bit for the relevant classes.
I am going to use WMI CIM Studio for this post on showing how to connect to SMS provider and the find the relevant classes for the Application deployment.
So fire on WMI CIM studio from Start Menu > All Progams > WMI Tools > WMI CIM Studio
This will essentially open up an IE page...click on "Allow Blocked Content" when it prompts.
Later a pop-up asking which namespace to connect to will be presented. By default it will try to connect to your local machine's Root\CIMv2 namespace.
Click on the below highlighted icon :
After this it will ask you to browse the namespace. In the machine name field fill in the Server having SMS provider installed and in the starting namespace fill in "root\sms\site_<3 letter SiteCode>". Click Connect.
WMI CIM Studio will then prompt you for the login. Check the highlighted box if you want to connect as the current user or supply alternate credentials which have access on ConfigMgr 07 to perform tasks.
After this press "Ok" and wait until WMI CIM studio retrieves the classes definitions from the namespace.
Once done it will loaded with whole lot of SMS WMI classes..... Click on a Class to see the member definitions (Properties, Methods and Associations)
Now as part of the automation quest ....I was set on finding to automate the deployment tasks we do manually now explained here in this post.
In nutshell as part of our deployment activity we manipulate collection by creating Query Membership CollectionRule to which we add a custom query having different machine names , machines which we want to see reflected in the application collection so that the related application advertisements show up on that machine for the end user to install...Pheww !
That being said.....If one doesn't have any idea about which classes to use...then just start with hit and trial approach.
Now I am going to search for classes with keyword collection in it...
Click on the little binocular icon on the WMI CIM studio.
Then enter "collection" keyword and hit Go button...then it will list all the classes containing the keyword "Collection" in it...Double-click the class to go to its definition. In this case am double-clicking on the class SMS_Collection .
After this we need to explore the SMS_Collection Class definition for the required property or method which will help us in creating QueryRules.
Go to the methods tab for this class.......
If you want to explore the method, just right-click and select Method Qualifiers
Check the Description what it says:
"This method is used to add new rules to the SMS_CollectionRule property. Returns the query ID if the rule was a query rule, 0 otherwise." <-- Voila
We can later explore the "Edit Method Parameters" (in above screenshot ) on how to invoke this method.
So I began making a list of interesting classes which help me in achieving the automation task I intended to do.
Few of these which you can explore are : SMS_Collection
Well the possibility are endless....if you are trying to manage distribution points then start exploring what WMI has to offer for them.
Similarly, go explore what you can do with packages, advertisements, programs etc.
More on this later.....Well we can always use PowerShell to query the WMI classes and check the members.
But I found this approach to do research better.
Next post I will explore on using already written PowerShell module for SCCM.