Configure a WMI Query Check Control (Windows)

Configure a WMI Query Check control to use a WMI query to check compliance on Windows hosts. You tell us the namespace to be evaluated and the WMI query you want to use. We'll report compliance posture at scan time.

 

Quick Links

User-Defined Controls | Regular Expressions (PCRE) | UDC FAQs

Using Agents? Jump to a section below

The help below applies when using Cloud Agents.

Examples of Common Namespace and WQL Query Combinations

Data Types Supported in WQL Queries by Cloud Agent

Important Notes

Best Practices

 

Examples of Common Namespace and WQL Query Combinations

See the following examples:

1) Get name and filesystem type for removable and fixed disks on system

namespace: root\cimv2

query: "SELECT Caption, FileSystem from Win32_LogicalDisk"

2) Network information

namespace: root\cimv2

query: "SELECT * from Win32_NetworkAdapterConfiguration"

3) Windows QFE patches information

namespace: root\cimv2

query: "SELECT HotFixID FROM Win32_QuickFixEngineering"

4) Windows process information

namespace: root\cimv2

query: "SELECT Name from Win32_Process"

Data Types Supported in WQL Queries by Cloud Agent

The following data types are supported by cloud agents:

sint8, sint16, sint32, real32, real64, uint8, uint16, uint32, uint64, real32, real64, uint8, uint16, uint32, char16, string, boolean, string array 

Qualys continues to add support for additional data types at regular intervals.

Important Notes

Please note the following:

1) To optimize performance, the report limit is set to 5000 records. 

2) WMI queries could have a significant impact on your domain controllers when using cloud agents. Starting with agent version 3.0 we'll skip calls to these WMI providers:

- Win32_NetworkLoginProfile (2008 Server R2 only)

- Win32_UserProfile (2008 Server R2 only)

- Win32_QuickFixEngineering – skipped starting in 3.1 unless “SELECT HotFixId FROM” is present

- Win32_UserAccount - This is the only query for Win32_UserAccount that will be handled by the agent. 

Example: SELECT Description, Name from Win32_UserAccount WHERE LocalAccount='true'

3) We don't support references, objects, maps, datetime, other types of arrays, etc. 

4) WMI providers are not created or suported by Qualys. The UDC feature merely gives a convenient way to execute the queries and gather the data.

Best Practices

Please note the following best practices:

1) WQL Queries should be valid queries. Please refer to the following for guidance: https://docs.microsoft.com/en-us/windows/win32/wmisdk/wql-sql-for-wmi

2) DOS/shell/VB scripts should not be added in UDC controls. 

‘select [valid item] from [existing namespace]’ is supported. 

It's specifically a Command control rather than file/registry/wmi collection. This is valid for all agent versions.

3) It is always recommended to use an optimized query. The more constrained the requested dataset is (selecting specific object/data and using WHERE clauses) the less impact it has on the system.

4) It is very strongly recommended NOT to use any WQL query whose WMI provider needs to reach out to network resources to gather the data. Doing so on many endpoints can cause excessive traffic to, from, and on the systems providing the information. Use a tool such as Wireshark to determine if this is the case. (This is the reason behind the limitation on the Win32_UserAccount provider).

5) WMI queries typically run in the wmiprvse.exe process. Some queries will cause this process to heavily use system resources. We recommend ensuring your queries aren't causing problems in this process.

6) Before creating UDCs, please test your WQL queries out using WbemTest.exe. This tool can be found in the %windir%\system32\wbem directory on Windows systems.

7) When executing the query to the custom providers, it is entirely up to whomever created that provider (quite often Microsoft) to determine how it will operate. If there appears to be an issue with a specific provider, check the WQL query with WbemTest. If it works in WbemTest.exe but not in the agent, contact Qualys. If it fails in WbemTest, you probably need to troubleshoot the query for problems (and/or contact the author of the provider).

8) On occasion WMI itself can cause problems. WMI is part of Windows, Qualys is leveraging it to execute the requested UDC WQL queries. There are issues that can crop up, such as the WMI repository becoming corrupt, WMI providers becoming unregistered, and other issues. Again, try out WbemTest.exe with the WQL query. If it works there, but not in the agent, contact Qualys. If it doesn't work there, it is being caused by a source other than Qualys.

9) Logging can be turned on for WMI in Windows. It is not recommended to turn this on unless absolutely needed. It can consume system resources quickly, particularly disk space.