How To Remove Dns Entry In Windows Server 2016
Summary: Using Windows PowerShell to remove Stale / Dead Domain Controller records. Q: Hey, Doctor Scripto! How tin can I quickly clean up all my expressionless Domain Controller'southward DNS records? A: That'southward a great question. The good Md also knows the very person to answer information technology best. My good friend Patrick Mercier, An Active Directory PFE who loves working with PowerShell. Have information technology away Patrick! Whether it'south as part of Agile Directory Disaster Recovery, or because you had an old Domain Controller you lot needed to get rid of, cleaning upward all the DNS records of a now dead DC left behind tin can be tedious: that is, unless y'all utilize PowerShell So, as an Active Directory PFE, one of the common things nosotros help customers out with is removing Domain Controllers from the environs. Sometimes that's as simple as the former DC that has to get abroad or as scary every bit having recovered Ad from backup and having to remove all other DCs as nosotros rebuild. Regardless of the scenario, cleaning DNS is a critical part of this and I've frequently constitute it to be the part that scares customers the most. I was cleaning upwardly records manually one mean solar day and equally I typically practice, I thought to myself, at that place has to be a amend style… and in that location is. Before I proceed though, this is not an Active Directory Disaster Recovery article. It's not a DNS make clean upwardly article. If you're looking for detailed explanations of all the DNS records this volition delete, y'all'll want to get find an article about Active Directory DNS! What I will do, is demonstrate an easy way to delete all DNS records related to a Domain Controller with a single PowerShell control. Get-go, let's create an assortment of all the records in the zone _msdcs.contoso.com: $dnsrecords = Get-DnsServerResourceRecord -ZoneName "_msdcs.contoso.com" This outputs everything in our zone. What nosotros get though isn't the full picture. The data we need to filter on is part of the "RecordData" information cavalcade which in and of itself is an array of data. And to isolate the DC we desire to make clean upwardly, nosotros'll demand to filter the resulting data. For that, we'll filter on some of the attributes available in the RecordData record fix, specifically, IPv4Address, NameServer and DomainName. $deadDC = $dnsrecords | Where-Object {$_.RecordData.IPv4Address -eq "192.168.50.xv" -or $_.RecordData.NameServer -eq "DC02.contoso.com." -or $_.RecordData.DomainName -eq "DC02.contoso.com."} Sugariness, now I have all the DNS records for my dead Domain Controller in 1 array! From here, it's super easy to delete them all, simply by calling the Remove-DnsServerResourceRecord cmdlet against the array and the zone! Because whatsoever skillful domain ambassador has a bit of paranoia congenital in, let'south run that equally a "What if" to confirm: $deadDC | Remove-DnsServerResourceRecord -ZoneName "_msdcs.contoso.com" -whatif And now, that I've got some peace of listen that aught I demand is being deleted, I simply remove the what if and the records are gone! No manual clean upwardly. So, if I were to bring all those components into 1 control, the result is: Get-DnsServerResourceRecord -ZoneName "_msdcs.contoso.com" | Where-Object {$_.RecordData.IPv4Address -eq "192.168.fifty.15" -or $_.RecordData.NameServer -eq "DC02.contoso.com." -or ` $_.RecordData.DomainName -eq "DC02.contoso.com."} | Remove-DnsServerResourceRecord -ZoneName "_msdcs.contoso.com" -force Simple actually. Cheers Patrick for an excellent tip to making all of this happen! And then that is all at that place is to using PowerShell to cleanup dead Domain Controller records. I invite you to follow the Scripting Guys on Twitter and Facebook. If you take any questions, ship email to them at scripter@microsoft.com, or post your questions on the Official Scripting Guys Forum. Run into you lot tomorrow. Until so always remember that with Great PowerShell comes Not bad Responsibleness. Your Expert friend, Dr. Scripto Windows PowerShell, Patrick Mercier, Scripter The post Clean up Domain Controller DNS Records with Powershell appeared showtime on Scripting.


Source: https://argonsys.com/microsoft-cloud/library/clean-up-domain-controller-dns-records-with-powershell/
Posted by: stocktonourthen1981.blogspot.com

0 Response to "How To Remove Dns Entry In Windows Server 2016"
Post a Comment