WMI replacement for Get-DNSClientCache

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.

Suggestions?

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.

Cheers

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

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.

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.

I’ve given a fairly brute force approach here: