In this article, we will discover what the WMI and WQL query is in a nutshell. Also, we will list some of the most common keywords of the WQL.
What is WMI?
MWI stands for Windows Management Instrumentation.
WMI is an interface that provides interoperability with system components. Using this interface, we can receive information about the computer infrastructure and manage its components, monitor, and administer.
A feature that will be important for system administrators is the ability of WMI to work with remote computers.
WMI includes a CIM-compliant (Common Information Model) database and a CIM object manager.
WMI allows us to get programmatic access to a huge amount of information regarding the hardware and software of a local or remote computer, including those that we can see using WINDOWS administration tools.
WMI provides powerful enough tools for working with events. So, for example, we can track the completion of a process on a remote computer.
What is WQL?
WQL, which is mentioned in the title of the article, is the language with which we can access WMI. The abbreviation stands for WMI Query Language, and this language is very similar to SQL.
To access WMI objects, we use the WQL query language built into WMI. Sometimes, we can also find another name – SQL for WMI.
This language is positioned as ANSI SQL compliant. At the same time, it is very much reduced, according to a purpose. Of all the statements, the only SELECT statement is allowed.
It is difficult to imagine that someone would want to use the UPDATE statement, for example, to update the type of computer processor. The type of processor is consistent, and it is simply pointless to change it.
However, in some WMI classes for working with equipment, we are allowed to change them, for example:
- The Win32_Fan class allows us to change the fan speed, where supported.
- The Win32_LogicalDisk class allows us to change the volume name.
- The Win32_NetworkAdapterConfiguration class supports a fairly large number of methods that allow us to change network adapter settings.
The following table contains the main keywords used in WQL.
|The main WQL keywords used|
|AND||Combines two logical expressions and returns TRUE if both expressions are TRUE.|
|ASSOCIATORS OF||Gets all instances that are associated with the source instance.|
|__CLASS||References the class of the object in the request.|
|FROM||Defines a class that contains the properties listed in the SELECT construct.|
|GROUP Clause||Creates one notification to represent a group of events.|
|HAVING||Filters events that were received during the grouping interval specified in WITHIN.|
|IS||Comparison operator with NULL. The syntax for this statement is as follows:
IS [NOT] NULL (Where NOT is optional)
|LIKE||An operator that determines whether a string matches a given pattern.|
|NOT||Logical negation operator.|
|NULL||Indicates an object that does not have an explicit value.
NULL is not equivalent to zero (0) or an empty value.
|SELECT||Specifies the properties that are used in the request.|
|TRUE||The logical meaning of truth.|
|WHERE||Defines selection conditions|
|WITHIN||When requesting events, determines the interval.|
|FALSE||The logical meaning of False.|
Table 1. The main WQL keywords
Example of WQL
WQL queries can be executed through the WMI Tester. We can type wbemtest.exe in the Run tab, as displayed in the picture.
Figure 1. Launching the WMI Tester
After this, the WMI Tester will be opened. First, we need to connect to the WMI namespace that contains the class we want to query (Root or Cimv2, for example):
Figure 2. Connecting to the WMI namespace
We can run the query upon clicking the “’Query” and “’Notification Query”:
Figure 3. Running a query in WMI
We can enter our query here. For example, let’s enter:
Select * From Win32_Process
Figure 4. Entering a query in WMI
After this, we need to click the “Apply” button, and the query results window will open:
Figure 5. Query results window in WMI
Instant livechat to an Expert!
Most of the time, the problem you will need to solve will be more complex than a simple method. If you want to save hours of research and frustration, try our live SQLExpert service!
Our SQLQuerychat Experts are available 24/7 to answer any questions you may have. We guarantee a connection within 30 seconds and a customized solution within 20 minutes.