Bobcares

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

For every $500 you spend, we will provide you with a $500 credit on your account*

BLACK FRIDAY SPECIAL

*The maximum is $4000 in credits, Offer valid till December 6th, 2024, New Customers Only, Credit will be applied after purchase and expires after six (6) months

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 _msdcs.bob.com:

$dnsrecords = Get-DnsServerResourceRecord -ZoneName “_msdcs.bob.com”

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 “192.168.50.15” -or $_.RecordData.NameServer -eq “DC02.bob.com.” -or $_.RecordData.DomainName -eq “DC02.bob.com.”}

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 “_msdcs.bob.com” -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 “_msdcs.bob.com” | `Where-Object {$_.RecordData.IPv4Address -eq “192.168.50.15” ` -or $_.RecordData.NameServer -eq “DC02.bob.com.” -or `$_.RecordData.DomainName -eq “DC02.bob.com.”} | Remove-DnsServerResourceRecord -ZoneName “_msdcs.bob.com” -force

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

Conclusion

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.

 

PREVENT YOUR SERVER FROM CRASHING!

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.

GET STARTED

var google_conversion_label = "owonCMyG5nEQ0aD71QM";

0 Comments

Submit a Comment

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

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