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,440 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

Featured Post

Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
Disabling the Directory Sync Service Account in Office 365 will stop directory synchronization from working.
This tutorial will walk an individual through locating and launching the BEUtility application and how to execute it on the appropriate database. Log onto the server running the Backup Exec database. In a larger environment, this would generally be …
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 to another domain controller. Log onto the new domain controller with a user account t…

911 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

16 Experts available now in Live!

Get 1:1 Help Now