Getting interfaces and their DNS servers that are STATIC (not dhcp allocated) RRS feed

  • Question

  • I'm trying to ge the DNS servers of network interfaces via WMI that are static (placed by the user). I have this script that works, except for the static part of course:

    Get-WmiObject Win32_NetworkAdapterConfiguration | Where-Object {$_.DNSServerSearchOrder -ne $null} | Select DnsServerSearchOrder,Index,InterfaceIndex

    This leads to an output like so:

    DnsServerSearchOrder   Index InterfaceIndex
    --------------------   ----- --------------
    {}            1              6
    {}                  2             10

    The interface with `` has it's DNS setup to DHCP so that value is not good for me. How do I filter out interfaces where dns is not static? Any ideas?

    Tuesday, January 14, 2020 4:59 AM

All replies

  • When in doubt look up the WMI class to see its properties and use the help for the CmdLet.

    Get-WmiObject Win32_NetworkAdapterConfiguration -Filter 'IpEnabled=True AND DHCPEnabled=False' |
        Select DnsServerSearchOrder,Index,InterfaceIndex


    Tuesday, January 14, 2020 9:39 AM
  • Hi,

    Was your issue resolved?

    If you resolved it using our solution, please "mark it as answer" to help other community members find the helpful reply quickly.

    If you resolve it using your own solution, please share your experience and solution here. It will be very beneficial for other community members who have similar questions.

    If no, please reply and tell us the current situation in order to provide further help.

    Best Regards,


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Tuesday, January 21, 2020 2:02 AM