472,956 Members | 2,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes and contribute your articles to a community of 472,956 developers and data experts.

DNS Server - PowerShell - Domain Controller Removal from Name Servers

300 256MB
As I head through a major refresh I realized it was way too cumbersome to manually remove decommissioned domain controllers from the 'Name Servers' tab inside of DNS forward and reverse lookup zones. I came up with the below script to automate the removal of these records. I hope this helps others in the future.

All you need to do is modify the FQDN (Fully Qualified Domain Name) on Line 2.

Expand|Select|Wrap|Line Numbers
  1.         #FQDN of the domain controller that has been decommissioned or is offline
  2.         $oldDMCName = "DMC1.domain.org"
  4.         #Get the PDC Emulator
  5.         $PDCe = Get-ADDomainController -Discover -Service PrimaryDC
  7.         #Get all DNS zones on the PDCe
  8.         $DNSZones = Get-DnsServerZone -ComputerName $PDCe
  10.         #Iterate DNS zones and remove the stale domain controller record where applicable
  11.         ForEach($zone in $DNSZones)
  12.           {
  13.             $zone = $zone.zoneName
  14.             $getZoneInfo2 = (Get-DnsServerResourceRecord -ZoneName $zone -Name "@" -RRType NS -ComputerName $PDCe).recorddata.nameserver
  15.             If($getZoneInfo -like "*$oldDMCName*")
  16.               {
  17.                 Try
  18.                   {
  19.                     Remove-DNSServerResourceRecord -ZoneName $zone –Name “@” –RRType NS –RecordData $oldDMCName -ComputerName $PDCe -Force
  20.                   }
  21.                 Catch
  22.                   {
  23.                     Write-Output "Error removing $oldDMCName from $zone"
  24.                   }
  25.               }
  26.             Else
  27.               {
  28.                 Write-Output "$oldDMCName does not exist in zone $zone"
  29.               }
  30.           }
Apr 26 '16 #1
1 18978
great man, that's amazing question to ask
Aug 17 '23 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

by: Douglas G. Walker | last post by:
Can anyone tell me how to get ASP to work on a Server 2003 domain controller? I keep getting 10004 errors in the system log. I've tried resynching passwords etc.
by: Frank | last post by:
I have observed that a temporary loss of a domain controller can cause problems creating new ado connections between a client machine running ado and a separate sql server machine that are members...
by: Michael Maes | last post by:
Hello, I can't get the ASPNET-Account installed on a Windows 2000 (5.00.2195) Server SP4 Domain Controller. I always receive "Web Server not running ASP.NET version 1.1" when I try to start a...
by: Richard Chandler | last post by:
We're having a problem with ASP.NET security and running on a Win2k Domain Controller. We can't set up the access rights to the registry for ASPNET as the user doesn't exist, this access is...
by: | last post by:
Hi all, I'm having some problems after upgrading a windows 2000 Server to Domain Controller. Symptoms: every aspx page returns blank HTTP Response headers: HTTP/1.0 200 OK Server:...
by: Richard | last post by:
First some background... I have an application whereby I send a mail, attach some attachments stored in the windows/temp directory and then send them. This works fine on 2 servers both are not...
by: SL | last post by:
How do I set up access to a file on a Windows Server 2003 Domain Controller that also has IIS? The file sits on another server. The Domain Controller / IIS server connects to this file through a...
by: Rob Roberts | last post by:
I have developed an ASP.NET 2.0 application using localhost on my Windows XP workstation, and it all works fine there. I tried to copy it to my test web server, which is a domain controller...
by: Kazmataz | last post by:
Hi, I have set my .net application to impersonate and is installed on a Web Farm of 4 servers. In this application I allow users to upload files to the server. I have it setup so that no matter...
by: SandVich | last post by:
i had two servers with Windows2000 Advance server OS. One is main Domain Controller and second on is additional. A problem occurred in additional domain controller and ultimately i had to format...
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.