What is WMI?
WMI is Microsoft’s primary management enabling technology for Windows. If you manage Windows servers and workstations, or if you create Windows management applications, you will most likely be familiar with WMI. WMI is not just a three-letter acronym tossed around to impress your colleagues. Make no mistake, knowing how to use the WMI scripting library to create a vast array of Windows system administration scripts is utopia for WMI enthusiasts.
While you can use WMI to manage both local and remote computers, WMI provides a consistent approach to carrying out day-to-day management tasks. For example, you can:
- Start a process on a remote computer.
- Schedule a process to run at specific times on specific days.
- Reboot a computer remotely.
- Get a list of applications installed on a local or remote computer.
- Query the Windows event logs on a local or remote computer.
These are just some examples, but there are a vast number of Windows processes and services that can be managed using WMI.
WMI Tools and Utilities
For those of us less adept in WMI, there are WMI tools and utilities that test (WBEMTest) and generate (Scriptomatic) WMI scripts. Let’s look at each utility:
Windows Management Instrumentation Tester
Most Windows operating systems have a utility called “Windows Management Instrumentation Tester” (or WBEMTest). WBEMTest is used to view and change Common Information Model (CIM) classes, instances, and methods. WBEMTest is also used to troubleshoot Windows Management Instrumentation (WMI) and programs that depend on WMI.
At the Run prompt, type wbemtest.exe and click OK. At the “Windows Management Instrumentation Tester” screen, select the “Connect” button to specify the following parameters:
Namespace: Default is root\cimv2
The "Namespace" contains a hierarchy of classes and associations which define either a machine’s object or the relationship between two or more objects.
Once “Namespace” has been defined, select the “Query” button to put in your query.
On the “Query” screen, enter the WQL query statement that will execute. For example:
SELECT * FROM Win32_process WHERE name="notepad.exe"
Click "Apply" to run the query and return the results.
Setting a WMI Trigger in Automate
The WMI trigger in Automate starts a task or workflow when a WQL query executes on a localhost or remote machine with an Automate BPA Server Agent installed. WMI uses the WMI Query Language (WQL) to submit WQL event queries and defines the type of events to be returned. WQL is Microsoft’s proprietary query language, similar to how SQL is a standard query language for accessing databases.
Setting a WMI Trigger requires that you provide various WMI parameters such as the WQL Query statement, Namespace (which is pre-populated with root\CIMV2), and the machine location (i.e., local or remote) where the WMI trigger is set to execute. Fortunately for us all, WMI offers full support for WQL queries out of the box. As previously stated, the combination of Microsoft’s Scriptomatic and WBEMTest utilities provide the resources needed to successfully execute WMI scripts.
You can download a sample WMI Trigger task for a quick test drive here.
Applies to: Automate 10