Require a PowerShell script to delete host and reverse lookup records in DNS of computers in a specific OU.
Posted on 2013-10-23
I would like assistance in crafting a PowerShell script (using only built-in cmdlets or command line apps, no 3rd party utils such a Quest) that will delete the DNS entries in the Forward and Reverse DNS zones for any computer accounts that are in a given OU.
So... let us say an OU is named "DisabledComputers". I'd like the script to run through the forward and reverse zones in "Domain.lcl" and remove any DNS records for the computers in that OU.
In other words, if a computer "WorkstationA" is in the OU named "DisabledComputers", I'd like the Host and PTR records for that computer removed from the "Domain.lcl" DNS zones. The script is essentially cleaning up DNS entries in real time as computers are expired from my domain for inactivity.
Yes, I use scavenging on a daily interval with default refresh/no-refresh periods. However, in this case, there are valid reasons why I don't want to wait for record expiration and scavenging.
Thanks in advance for your help.