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
All,
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"
  3.  
  4.         #Get the PDC Emulator
  5.         $PDCe = Get-ADDomainController -Discover -Service PrimaryDC
  6.  
  7.         #Get all DNS zones on the PDCe
  8.         $DNSZones = Get-DnsServerZone -ComputerName $PDCe
  9.  
  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

1
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.
2
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...
1
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...
3
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...
13
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:...
0
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...
1
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...
0
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...
1
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...
0
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...
0
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=()=>{
2
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...
2
isladogs
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...
0
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...
0
tracyyun
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...
4
NeoPa
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 :...
3
NeoPa
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...
0
NeoPa
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...
0
isladogs
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.