Get-WmiObject to get Specific DNS records

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

  • Author
  • #62853


    Hi all,

    I'm trying to get a list of static DNS A Records. I've tried doing a double filter, adding a Where-object statement at the end of this line, but everything errors out on me. I also thought about putting the results of this into a variable, and then running an IF statement, but that didn't work either. Get-dnsserverresourcerecord only returns the hostname, and I need the FQDN that this line returns. Does anyone know what I should add to the following line to get this to work? $zonename is variable that's working fine. If the one line can't do what I'm looking for, can you point me in the right direction? TIA

    Get-WmiObject -Class MicrosoftDNS_AType -NameSpace Root\MicrosoftDNS -ComputerName  -Filter "DomainName = '$zonename'" | Select-Object -property Ownername, IPAddress, Timestamp
  • #62863

    Don Jones

    I think I'm possibly not following what it is you want, which this does not do...?

  • #62865


    That line works, but returns the non-static records too. I need a way of only getting the static records.

  • #62866


    Ah – someone in another forum got it, so the correct answer for those wondering is:

    Get-WmiObject -Class MicrosoftDNS_AType -NameSpace Root\MicrosoftDNS -ComputerName -Filter "DomainName = '$zonename' AND TimeStamp = 0" | Select-Object -property Ownername, IPAddress, Timestamp


  • #62949

    Richard Siddaway

    Its easier if you use the cmdlets from the DNSserver module

    Get-DnsServerResourceRecord -ComputerName W16DC01 -ZoneName '' -RRType A |
    where {-not $_.TimeStamp}

    Also I'd recommend using Get-CimInstance rather than Get-WmiObject

You must be logged in to reply to this topic.