Relevance question needed with WMI

(imported topic written by dan12345991)

I need to create a relevance using WMI. IF someone has some Ideas, that would be great.

The normal query I was told using WMI straight is as follows: SELECT * FROM win32_PnPEntity WHERE DeviceID LIKE ‘%VEN_1022%’

I need to verify if a deviceID Win32_PnPEntity includes the string VEN_1022.

When I run the basic q/a.exe using the following question, I get the following answer (just a subset):

q: (selects (“DeviceID from Win32_PnPEntity”) of WMI)

A: DeviceID=ACPI\PNP0700\5&324D5432&0

A: DeviceID=FDC\GENERIC_FLOPPY_DRIVE\6&1435B2E2&0&0

A: DeviceID=PCI\VEN_1022&DEV_2000&SUBSYS_20001022&REV_10\3&61AAA01&0&88

A: DeviceID=PCI\VEN_8086&DEV_7111&SUBSYS_197615AD&REV_01\3&61AAA01&0&39

A: DeviceID=PCIIDE\IDECHANNEL\4&23686003&0&0

As you can see, There is a DeviceID with “VEN_1022” in the string. Could someone help with what the relevance would look like to see if a computer has a DeviceID with the “VEN_1022” string.

Thank you,

Dan

(imported comment written by BenKus)

Hi Dan,

You are very close… There are basically two ways to do this:

Use WMI to do the filtering for you using a “where” clause in the same way you mentioned (but note that the “%” need to be escaped by using “%25” because relevance uses percent encoding):

(string values of selects (“DeviceID from Win32_PnPEntity WHERE DeviceID LIKE ‘%25VEN_1022%25’”) of WMI)

or (depending on what value you want back):

(exists string values of selects (“DeviceID from Win32_PnPEntity WHERE DeviceID LIKE ‘%25VEN_1022%25’”) of WMI)

This should work well for you, but note that our experiences tell us that the WMI “LIKE” operator doesn’t work on certain Windows OSes (Win2000 and below)… In cases like this or when you want to do more filtering of the data, you can do it in relevance:

it whose (it as lowercase contains “ven_1022”) of (string values of selects (“DeviceID from Win32_PnPEntity”) of WMI)

Hope that helps,

Ben

(imported comment written by dan12345991)

Ben,

Thank you very much. This worked like a charm.