Understanding WMI Scripting

In previous chapters, we examined the WMI architecture, WMI-related tools, and WQL. We now have the necessary knowledge to start the discussion of WMI scripting. Scripting on top of WMI implies the use of WMI COM objects. A script uses two types of objects: the objects obtained from the various class definitions located in the CIM repository (instances) and the objects exposed by the WMI scripting API (COM objects). As previously mentioned, in order to script on top of a COM abstraction layer, it is important to know how to navigate in the object model. To script on top of WMI, it is important to master both object models: the CIM repository object model and the WMI COM API object model. In Chapter 2, we focused on the tools that help understand and discover the CIM repository. In this chapter and the next, we focus on the WMI scripting API and show how this API can help to instantiate objects from the CIM repository and retrieve information about the CIM classes. We also find out how to work with real-world managed objects via this API by using CIM representations. The WMI scripting API is a collection of COM objects usable from most programming languages (such as Visual Basic or C++) and scripting languages (such as VBScript or JScript). In order to use the WMI COM objects they must first be instantiated. In addition, the CIM repository classes must also be instantiated as objects in order to reference the...