Understanding WMI Scripting

In the previous chapter, we examined the WMI scripting object model with its basic operations to retrieve real-world manageable object information. Although, we perform the exact same task in this chapter, we explore some advanced scripting techniques with the same set of WMI scriptable objects. In the previous chapter, we used a specific set of methods that implemented synchronous scripting techniques, which resulted in a WMI operation (i.e., retrieving instance information) executing in-line with the code execution. In this chapter, we see how to use the WMI asynchronous operations by examining another set of methods available from the same WMI object collection. The asynchronous scripting techniques allow the execution of one more subroutine in parallel, which increases the execution performance. WMI extends ADSI by adding new properties and methods to facilitate the instantiation of some WMI scriptable objects. Moreover, WMI also exposes some helper objects to manipulate the DMTF date format or to retrieve instance information in XML. Let's see how these advanced features work.
The SWbemServices and SWbemObject objects expose various methods to perform different tasks (see Tables 4.8 and 4.10). Some of these methods are executed in line with the script code and force the script to pause until the method is executed (synchronous execution). Depending on the action to be performed, some methods may take some time to execute (i.e., stopping the Exchange Information Store service of an Exchange server hosting a mailbox store of 25 GB...