WMI query to determine DNS servers without null records

I can use the following WMI query to determine any DNS servers that my machine can use:

SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration 

However, the following query that 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 null entries?

+4
source share
3 answers

The WQL language supports != And the syntax IS [NOT] NULL , the problem is the property that you select DNSServerSearchOrder is the array, and you cannot use the array property in the WQL Where clause . Thus, a workaround is to use another property of the Win32_NetworkAdapterConfiguration WMI class in the where Win32_NetworkAdapterConfiguration .

+7
source

Just use this

 WHERE IPEnabled=True 
+1
source

You are looking for this instead:

 SELECT DNSServerSearchOrder FROM Win32_NetworkAdapterConfiguration WHERE DNSServerSearchOrder IS NOT NULL 
-1
source

Source: https://habr.com/ru/post/1483264/


All Articles