Search code examples
wmi

WMI Query to determine DNS Servers without null entries


I can use the following WMI query to determine any DNS servers my machine might be using:

SELECT DNSServerSearchOrder
FROM Win32_NetworkAdapterConfiguration

However, the following query I wrote to ignore null entries is invalid and I don't know why:

SELECT DNSServerSearchOrder
FROM Win32_NetworkAdapterConfiguration
WHERE DNSServerSearchOrder!=null

Is there a way to filter out the null entries?


Solution

  • The WQL language supports != and the IS [NOT] NULL syntax, the problem is the property which you choose DNSServerSearchOrder is an array, and you can't use an array property in a WQL Where sentence. So the workaround is use another property of the Win32_NetworkAdapterConfiguration WMI class in the where condition.