Author Posts

January 27, 2017 at 6:18 pm

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 192.168.1.1  -Filter "DomainName = '$zonename'" | Select-Object -property Ownername, IPAddress, Timestamp

January 27, 2017 at 6:44 pm

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

January 27, 2017 at 6:47 pm

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

January 27, 2017 at 6:58 pm

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

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

Thanks!

January 29, 2017 at 3:53 pm

Its easier if you use the cmdlets from the DNSserver module

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

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