WMI replacement for Get-DNSClientCache

Welcome Forums General PowerShell Q&A WMI replacement for Get-DNSClientCache

This topic contains 4 replies, has 4 voices, and was last updated by

 
Participant
3 years, 6 months ago.

  • Author
    Posts
  • #26838

    Participant
    Points: 1
    Rank: Member

    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?

  • #26839

    Participant
    Points: 0
    Rank: Member

    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

  • #26854

    Participant
    Points: 1
    Rank: Member

    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

    Moderator
    Points: 24
    Team Member
    Rank: Member

    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

    Participant
    Points: 0
    Rank: Member

    I've given a fairly brute force approach here:
    Parsing ipconfig /displaydns

The topic ‘WMI replacement for Get-DNSClientCache’ is closed to new replies.