SMS applications and scripts work with WMI through the WMI Object Model, which defines the programming interface to WMI. A number of WMI object types are used when manipulating SMS objects. For more information about the WMI Object Model, see the WMI SDK.
In simple SMS scripts, you use the following WMI object types:
|Understanding WMI Query Language (WQL) queries is very
important for identifying which SMS objects you want to read. WQL
statements allow you to retrieve SMS objects based on SQL-like
queries. For example, the following WQL statement is used to
identify all Windows Server 2003 systems:
The SWbemLocator object is used to create an authenticated connection to the SMS Provider. You use SWbemLocator.ConnectServer method to make the connection to the SMS Provider. This method is particularly useful if you need to pass user credentials to a remote SMS server during connection. You can also use the Windows Script Host GetObject method to create an authenticated connection. The type of object returned by GetObject depends on the parameters passed to it. See How to Connect to an SMS Provider for examples showing how to use either SWbemLocator or GetObject in your connection script.
The SWbemServices object represents an authenticated connection to an SMS Provider, and it is the object you use to retrieve SMS objects. You receive an SWbemServices object as the return value of the SWbemLocator function ConnectServer or, alternatively, as the return value when the GetObject method is used to connect to the SMS Provider. SWbemServices has several methods, but you use only the Get, ExecQuery, and InstancesOf methods for retrieving objects.
Get returns a single instance of an SMS object (SWbemObject). ExecQuery and InstancesOf return SMS objects in a collection (SWbemObjectSet) of SMS objects.
The SWbemOjectSet object represents a collection of SMS objects. You can use it to enumerate through the collection and read individual instances of the SMS object (SWbemObject) that you are interested in. You typically get an SWbemObjectSet object returned to you from the SWbemServices retrieval functions.
The SWbemObject object allows you to access the properties and other information for an SMS object.