WMI replacement for Get-DNSClientCache

Tagged: ,

This topic contains 4 replies, has 4 voices, and was last updated by Profile photo of Richard Siddaway Richard Siddaway 1 year, 4 months ago.

  • Author
  • #26838
    Profile photo of Jeffrey Wagar
    Jeffrey Wagar

    Since the DNS Client module is not available on Windows 7 computers (or Windows XP), I have spent the day unsuccessfully looking for the WMI Class and particularly the correct syntax to perform the same task with Get-WmiObject. I could use ipconfig /displaydns but prefer to work with the more formal WMI, if possible. Get-WmiObject also has the -ComputerName parameter, which would let me poll remote computers, instead of wrapping ipconfig in a Invoke-Command temporary session.


  • #26839
    Profile photo of Flynn Bundy
    Flynn Bundy

    Hey Mate,

    You can use something like this to display you the DNS configuration of a server.

    Get-WmiObject -class Win32_Networkadapterconfiguration | select -ExpandProperty DNSserversearchorder 

    If you wanted to have a bit more detailed output you could take off the expandproperty and add something like.

     select __Server,DNSServersearchorder -Unique 

    hopefully this is a point in the right direction.


    Edit: just noticed you were after the Client Cache, I should really read the question first. haha

  • #26854
    Profile photo of Jeffrey Wagar
    Jeffrey Wagar

    It is the DNS Resolver Cache on local Windows 7 workstations I am trying to poll by WMI, to get the same information "ipconfig /DisplayDNS" returns. Since Windows 7 will be supported until 2020, people will need a workaround for Get-DNSCache, which only is available on Windows 8/Server 2012.

  • #26855
    Profile photo of Daniel Krebs
    Daniel Krebs

    The DNS client cache is not available as WMI class in Win7 and earlier unless you code your own using the Windows APIs.

    You will need to use ipconfig /displaydns or find a 3rd party tool which might do the same in a better output format. There are several examples on the web how to parse the output of ipconfig /displaydns.

  • #26903
    Profile photo of Richard Siddaway
    Richard Siddaway

    I've given a fairly brute force approach here:

You must be logged in to reply to this topic.