Manual DNS Scavenging with PowerShell

Hello,

If you want to do a manual DNS scavenging to remove stale records, you can use this PowerShell oneliner :

Get-DnsServerResourceRecord -ZoneName D2K12R2.local | ? {($_.Timestamp -le (get-date).adddays(-30)) -AND ($_.Timestamp -like "*/*")} | Remove-DnsServerResourceRecord -Force  -ZoneName D2K12R2.local

You can adapt the “Where-Object” to fit your needs, as well as the “ZoneName” parameter on both DNS cmdlets.

Leave a Reply