Call Us! 1-800-383-5193
Call Us! 1-800-383-5193
Call Us! 1-800-383-5193

Need Help?

Emergency Response Time custom

Our experts have had an average response time of 12.45 minutes in December 2020 to fix urgent issues.

We will keep your servers stable, secure and fast at all times for one fixed price.

Domain Controller DNS Records – Clean up with Powershell

by | Jan 6, 2021

Domain Controller DNS Records can be cleaned up with Powershell.

At Bobcares, we often handle similar requests from our customers as part of Server Management Services.

Today let’s see how our Support Engineers do this with the help of Powershell.

How to Clean up Domain Controller DNS Records?

One method that our Support Techs follow is to clean up Stale/Dead Domain Controller records by using PowerShell.

We know that Windows 7 and all orther later version usually have PowerShell.


 domain controller dns records


Steps to follow are given below:

1. First, we create an array of all the records in the zone

$dnsrecords = Get-DnsServerResourceRecord -ZoneName “”

The data we filter is part of the ‘RecordData’ data column which is inside an array and an array of data itself.

2. Next, we can separate the Domain Controller(DC) for clean up. And for doing this we have to filter the resulting data

We can filter this data depending upon some of the attributes such as IPv4Address, NameServer, and DomainName which are available in the RecordData recordset.

$deadDC = $dnsrecords | Where-Object {$_.RecordData.IPv4Address -eq “” -or $_.RecordData.NameServer -eq “” -or $_.RecordData.DomainName -eq “”}

3. Once this is complete we have all the DNS records for dead Domain Controller in an array.

Usually, it is easy to delete them all. And this can be done simply by calling the Remove-DnsServerResourceRecord cmdlet against the array and the zone.

$deadDC | Remove-DnsServerResourceRecord -ZoneName “” -whatif

4. We must ensure that we do not delete anything of relevance.  All we have to do is simply remove the ‘whatif’  since this will delete the record.

Generally, after doing this there will not need a manual clean-up.

So, can bring all those components into one command to get the following result:

Get-DnsServerResourceRecord -ZoneName “” | `Where-Object {$_.RecordData.IPv4Address -eq “” ` -or $_.RecordData.NameServer -eq “” -or `$_.RecordData.DomainName -eq “”} | Remove-DnsServerResourceRecord -ZoneName “” -force

[Need assistance to clean up domain controller records? We can help you!]


To conclude, we saw how our Expert Support Engineers clean up Stale/Dead DC DNS records with the help of PowerShell.

Also, we saw how easy it is to clean up domain controller records with the help of this method using few Windows PowerShell commands.



Never again lose customers to poor server speed! Let us help you.

Our server experts will monitor & maintain your server 24/7 so that it remains lightning fast and secure.


var google_conversion_label = "owonCMyG5nEQ0aD71QM";


Submit a Comment

Your email address will not be published. Required fields are marked *