top of page

PowerShell | Get-DnsServerResourceRecord

When working on DNS Records we have to audit the left over Static entries that won't scavenge out.

Query them for review. Note: Ran locally on DC and Run as Administrator

This looks for host A records with a NULL Timestamp

Get-DnsServerResourceRecord -ZoneName "MyNewForest.local" | Where{($_.RecordType -eq "A") -and ($_.Timestamp -eq $NULL)}

Had a list of old computer objects that had not checked in, in over 90 days, wanted to
loop through list and see if they existed in DNS. Since we had scavenging enabled all of
the old records were removed but one. The record found, I checked Timestamp and removed
it from the project.

This simply imports a list of computers and checks to see if there is a Host A record for it in DNS

$List = Get-Content C:\temp\ServerList.txt

Foreach($Comp in $List){
    Get-DnsServerResourceRecord -ZoneName "MyNewForest.local" -ErrorAction Continue | Where{$_.HostName -eq $Comp}`
    | Select HostName,RecordData,Timestamp | Export-CSV C:\temp\MyDNS.csv -NoTypeInformation -Append

bottom of page