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,642 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Visualize your virtual and backup environments

Create well-organized and polished visualizations of your virtual and backup environments when planning VMware vSphere, Microsoft Hyper-V or Veeam deployments. It helps you to gain better visibility and valuable business insights.

Question has a verified solution.

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

A hard and fast method for reducing Active Directory Administrators members.
This process allows computer passwords to be managed and secured without using LAPS. This is an improvement on an existing process, enhanced to store password encrypted, instead of clear-text files within SQL
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…
Sometimes it takes a new vantage point, apart from our everyday security practices, to truly see our Active Directory (AD) vulnerabilities. We get used to implementing the same techniques and checking the same areas for a breach. This pattern can re…

615 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