Browse DevX
Sign up for e-mail newsletters from DevX


Exploring WMI Part II: Using the Common Information Model : Page 3

Part II of this WMI tutorial series discusses details of the Common Information Model Version 2 (CIMV2) schema and shows you how to query CIM to obtain detailed information about CIM objects.




Building the Right Environment to Support AI, Machine Learning and Deep Learning

Navigating the CIM
Figure 2. WMI Extensions Object Browser: The figure shows the hierarchical tree view of CIM object displayed by the WMI Extensions Object Browser.
To work effectively with CIMV2 you must first decide exactly what data you want to manage. Many problems can be solved by using just parts of the hierarchies rather than the entire model. You certainly won't need to break down every Win32_Service instance to its CIM_ManagedSystemElement just to write a simple service manager. But you will need sufficient knowledge to find appropriate associations in the schema to get all the data you want. Finding all the users of a group isn't easy without knowing the associations. Base classes depend on the cardinalities of a managed object. An object may have more than one value for a given property when a class contains multi-valued properties such as a value array (for properties) or a one-to-many relation (for associations). This situation is sometimes referred to as the cardinality of the property or relationship. Identifying cardinality is important, because it's typically a fundamental part of the property or relationship definition. You express the cardinality of relationships using Max and Min qualifiers on the references and the cardinality of properties using array syntax and an ArrayType qualifier on the property.

For example a Win32_Process is not only associated with the Win32_ComputerSystem on which the process is running. It is also related to CIM_DataFile objects representing the files used by the process. In this case you'd have two cardinalities on the relation (see Listing 1). WMI Extensions Object Browser
Explaining a generic way to locate objects in any CIM implementation would be far beyond the scope of this article; however in the WMI implementation, the easiest way to find objects is to use the Windows Management Instrumentation Extensions for Microsoft Visual Studio .NET. After installing the extensions you'll see two new nodes in the Server Explorer panel: Management Classes and Management Events (see Figure 2).

The screenshot shows the CIM filtered and sorted for the relevant objects in the Windows environment. Although this appears to be a complete list it is actually missing many objects because the WMI Extensions object browser shows only Management Classes that have instances. For example, a Win32_PrintJob won't appear in this list because it is instantiated only while a document is being printed. Despite its limitations, the WMI Extensions browser provides a good place to start exploring the WMI model. You can get further details about any object by right-clicking on it and selecting the Properties menu item. Information relevant to the selected object appears in the properties window.

Figure 3. The Win32_SystemBIOS Management Class: The figure shows the members of the Win32_SystemBIOS Management Class as shown in the WMI Object Browser.
The Management Events Node is a tool that lest you test WMI Events inside VS.NET. You can register for a management event and see the results in the output pane of VS.NET. We will look further into events in a later article, explaining all the event stuff would be far beyond the scope of this article. WMI Object Browser
A more powerful WMI object browser called CIM Studio ships with the WMI SDK. Although it's more difficult to use, this version lets you browse through the currently running instances of CIM classes, and also provides much more detailed information than the WMI Extensions for VS.NET browser.

By default the Win32_ComputerSystem object is the root object; all other objects appear lower in the tree; their exact position depends on their association with the root object and with each other. If you want to zoom in on just a portion of the hierarchy you can right click on any object and make it the new tree root. The right pane gives you detailed information about properties, methods and associations of an object.

Figure 4. Associator Relationship Example: The Win32_SystemBIOS class is the Associator class for the Win32_ComputerSystem and Win32_BIOS classes.
The methods and properties are self-explanatory, but associations aren't as transparent. You'll find all the relevant information you will need to find associated objects under the Associations tab. In this example you can see an instance of a Win32_BIOS class which is associated with the Win32_ComputerSystem class. The association is handled by an associator class, in this case Win32_SystemBIOS. Figure 3 shows how this class looks in the CIM Studio:

The class shown in Figure 3 has two key properties: GroupComponent and PartComponent (see Figure 4). The GroupComponent references the Win32_ComputerSystem instance containing the BIOS of the association and the PartComponent references Win32_BIOS contained in the computer system of this association.

Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date