Solved

Require a PowerShell script to delete host and reverse lookup records in DNS of computers in a specific OU.

Posted on 2013-10-23
1
2,399 Views
Last Modified: 2013-12-09
Folks -

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.
0
Comment
Question by:amendala
1 Comment
 
LVL 53

Accepted Solution

by:
Will Szymkowski earned 500 total points
ID: 39594992
There are no native Powershell cmdlets to accomplish what you are doing for server 2008. If you are using Server 2012 you can do this natively.

For server 2008 there has been a script to accomplish this using dnscmd to modify DNS records.

PS Script Download - http://gallery.technet.microsoft.com/scriptcenter/Update-DNS-records-with-da10910d

You will need to add your list of computers to the script via CSV file.

You can use the below script to get a list of computers from the DisabledComputers OU and then export them to a csv file. From there you put the file path into the PS script found at the download link...

Get-ADComputer -Filter * -SearchBase "OU=DisabledComputers,DC=domain,DC=com" | select DNSHostName | Export-csv "c:\computers.csv"

Will.
0

Join & Write a Comment

Sometimes drives fill up and we don't know why.  If you don't understand the best way to use the tools available, you may end up being stumped as to why your drive says it's not full when you have no space left!  Here's how you can find out...
Possible fixes for Windows 7 and Windows Server 2008 updating problem. Solutions mentioned are from Microsoft themselves. I started a case with them from our Microsoft Silver Partner option to open a case and get direct support from Microsoft. If s…
This tutorial will give a an overview on how to deploy remote agents in Backup Exec 2012 to new servers. Click on the Backup Exec button in the upper left corner. From here, are global settings for the application such as connecting to a remote Back…
This tutorial will walk an individual through the process of transferring the five major, necessary Active Directory Roles, commonly referred to as the FSMO roles from a Windows Server 2008 domain controller to a Windows Server 2012 domain controlle…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now