Correctly renaming a Domain Controller for a seamless easy migration
Renaming a domain controller using netdom so migrations are seamless to end users
This article is for you if…
- You have a Windows 2019 server (these steps are also applicable to 2022, 2016 and 2012 R2)
- You want to rename your domain controller
- You renamed your domain controller wrong and now you see DCDIAG errors and references to the old name
- You manually updated the File Replication Service entries in Active Directory.
- You renamed your Domain Controller via the System GUI
This article assumes that your have an existing DC to rename or a new DC installed you are wanting to move to, follow this guide to install the Server OS if not.
If don’t already have a domain in place then it might be best to head over to this guide which will guide you through setup of a new forest and domain.
If you are running in a none production environment and are following this guide for testing only you can download an evaluation copy of Server 2019 from Microsoft here.
Words of caution
If you rename your DC by renaming a Domain Controller in the normal way you would rename a computer (using the System > Rename this PC gui), you didn’t do it right and your metadata is likely irreversibly damaged.
However, I have seen success in this situation when multiple DC’s exist by demoting a re-promoting the DC. If only a single DC exists I would say its maybe a good idea to follow the below guide as it may get your out of the proverbial but probably not recommended and you may have to rely on backups.
We take no responsibility if you get this wrong. However, if you do have issues we are happy to respond to emails.
What will happen to clients using this DC?
During the renaming process the below services will be impacted but can be mitigated by having a second DC in place.
- DNS – any client that are using your server for DNS while the process is taking place will not be able to request DNS resolves. The lookup zones will be re-created during this process and may take time to regenerate.
- DHCP – If DHCP is installed on the server also this won’t be affect by the rename itself but will be during the server reboot which is a requirement.
- Any other services for example File Services, Print Management etc – The rename wont affect these directly but it will be affected during the reboot.
Command Generation tool
**NEW** – Try out our command generator to rename your Domain Controller here
Step 1: Getting ready.
Open a command prompt. (Windows key+r (run) + cmd)
Step 2: Adding an alternate computer name.
SYNTAX : netdom computername <currentDC FQDN> /add:<newDCName FQDN>
In the command prompt, type (minus quotes) “netdom computername wrongname.domain.local /add:server.domain.local“
This should return with “Added (NAME) as an alternate name for the computer. The command completed successfully.“
To check the name has applied correctly run “netdom computername server.domain.local /enumerate” you should then see there are two names listed.
Step 3: Make the new name the primary.
SYNTAX: netdom computername <currentDC FQDN> /makeprimary:<newDCName FQDN>
Type netdom computername wrongname.domain.local /makeprimary:server.domain.local
IMPORTANT: This command will return successful, and warn you that you need to reboot immediately, as it may not authenticate logons (very important if only DC in forest)
If the command is successful you will get the below message.
Step 4: Reboot the server.
Pick your poison. I like “shutdown /r /t 0” in the cmd.
Step 5: Check new server name.
Go to system properties and confirm new computer name. Or run “netdom computername server.domain.local /enumerate” to see both active names.
Step 6: Remove old hostname.
SYNTAX: netdom computername <newDCName FQDN> /remove:<oldDCName FQDN>
(remember, in a command prompt)
Type “netdom computername server.domain.local /remove:wrongname.domain.local“
Step 7: Paranoia.
in cmd, run a “dcdiag” to make sure everything is AOK.
Step 8: Clean up.
If you use logon scripts, remember to update the UNC paths with the new server name.
For any further help in renaming a domain controller please contact us here
I like the valuable information you provide in your articles.
I’ll bookmark your blog and test once more here regularly.
I am somewhat sure I’ll be told many new stuff right here!
Best of luck for the next!
so when I try to run the command I get an error: Cannot create a file when that file already exist.
I am trying to rename a DC to have the name of an old DC that was demoted and removed from the network. The old DC is completely gone, properly demoted, verified it is no longer listed in sites and services. Not sure what else to check.
Hi,
Have you checked in DNS for any record of the server, also check AD to ensure the computer account has gone? If not try running a Meta Data clean-up to remove any lingering records of the old Domain Controller – Good article here https://docs.microsoft.com/en-gb/windows-server/identity/ad-ds/deploy/ad-ds-metadata-cleanup
Thanks a lot, working great, i had a trust relationship established between two DC, that i removed the time to rename my new DC, then created the trust relationship back, i had no trouble except an error running DCDiag : the test failed for DFSREvent but i have only One DC so nothing to replicate to : for me its a false positive .
Excellent! Glad it worked for you Alexandre.
Great article!
My current environment has two DCs, replicating to one another. How can I rename the DC with your approach? What should I be concerned about? Any advice?
If the dcs are virtual I would standard snapshot both then you can go ahead and rename the required dc. Once done and you have checked replication and logins are all working remove the snapshots.
cant ever really revert a snapshot on DC’s. it can cause boo boo’s. have you ever seen it work?
Great info here lad and a simple solution for a newbie like me. I wish to know it before messing with my test server computer name…
You;re welcome glad you found it helpful!
I took over my domain/network environment from a former Network Admin over a year ago. One of my 2 replicated DCs is called TEMP-DC-10 and I have been wanting to change it to match the naming scheme for the rest of the Hyper V servers on the domain. But I was afraid of all the unknowns that could happen from this. but now this gives me the confidence to do it. I’m going to give this a shot over the weekend.
Thanks for writing this up!
No worries. If your dc is virtual why not take a snapshot of both dc’s prior incase it messes up you can revert both.
Yeah, I plan to. Plus I have nightly Altaro VMBackups as well…
Perfect it’s always best to have a regression plan.
Hi,
I have AWS EC2 Win2019 Instance that acts as Domain Controller. By default it has got the AWS provisioned name.
I have removed the Instances from DC and followed the above steps . Now I am unable to login to it.
Any suggestions?
Question, If I want to keep the old server (2008) running as a secondary server and backup dns (until I replace it) but just change the name of it and then also renaming my new server with the old name will I have any issues ?
Personally I think you would be better following this guide, then promoting a new server for a secondary. Domain controllers can do weird things when old DCs exist, plus for this to work correctly there needs to be no record of the old one at all otherwise it will fail.
2-x-Thumbs Up
Hey, glad this was helpful!
Hi all!
i did that job – migration from 2008R2 up to 2019- twice. Once on GUI, directly, and glamorous failed . After reinstalling Windows 2019, and following your suggested way, it got to success.
Thanks for publishing!
Thank you for this how-to. But I have a question for you. I have 2 2012 R2 DC. 1 is virtual – Primary and the 2nd is physical – secondary, backup, I have a new VM 2019 Server created. I am going to migrate the Primary data to the new 2019. I want the new 2019 DC to have the same IP address as the old DC and the name, so I don’t have to go to all the places I have the DNS server info hard coded. Will your method here work in this scenario?
Then I am going to upgrade the physical server to 2019 by demoting and doing in an place upgrade. Can I keep the old VM DC as secondary? It is kind of related to your article.
Hello from Brazil!
I have a question: if I have a domain whose fqdn is myenterprise.local and I wish to rename it to myenterprise.com.br or ad.myenterprise.com.br, can I use this tutorial?
Gratz for your work!
Hey, unfortunately not. This guide is to rename a domain controller not the domain. In all honesty I wouldn’t attempt a domain rename either stick with the existing or start a fresh the can of worms you will open you’ll end up starting again anyway.
I messed up a 2019 DC by renaming it incorrectly. Now my NETLOGON service does not start. DCDIAG still is looking at the old name and says the GC, AD etc… cannot be found.
IS there anything I can do to fix this mess?
Hi,
If you run the enumerate command does it return the names? I would try running with both the old a new hostnames.
netdom computername server.domain.local /enumerate
If you can get this to return a result there is a good chance it can be rescued.
at teh begining you rename server to old and then demote the server.
do you rename from the gui without issues
Hi,
I have one domain controller and I’m spinning another with new hardware.
1. Do I promote the new domain controller?
2. Then demote the old one?
3. The rename the new old and change the ip?
Yes, basically.
Promote a new DC, completely remove the old then rename the new to the old name and give it the same IP, should be seamless to end users.
Do I need to run the syntax, starting with step#2?
Cheers,
Kevin
Correct
How about demoting the current DC (with another one on the network) then renaming in the GUI. Then on the new server rename it in the GUI to the old name then promote it to DC?
Renaming in the GUI will break your domain, unfortunately, as it does not update the name in other locations which is required. Doing this, you will end up either rolling back backups or re-creating your domain.
hey, let’s say i have olddc1 and newdc1 then demoted olddc1 and promoted newdc1 . So if i rename newdc1 to olddc1 , other DCs won’t recognize my newdc1 with olddc1 name because it has demoted. So what should i do ?
You should promote the new DC prior and then demote the old, remove any traces of the old from AD and then add the old name to the new DC then remove the old you should have no issues.
I have two DC’s in different subnets. The Sysvol folder is acting weird. Sometimes.
I’ve narrowed it down to the following:
-sysvol contents are different on both machines
-replication completes successfully, yet missing items on the secondary.
-going to //domain.local/sysvol -works
-going to //machinename12345/sysvol -does not work
-going to //machinename1234/sysvol -works (note 15 chars!)
I had to make a DNS entry for machinename1234 to resolve because the server us using the 16 char version for it’s DNS entry.
It looks like the NETBIOS limit might be the culprit in the intermittent failures I’m seeing when workstations apply. When the second DC is the login server for the workstation, it works. When the primary is the login server, it fails.
Will renaming the primary DC to the machinename1234 to bring it to the NETBIOS 15 char limit maintain the replication and whatnot or will I have to redo the replication? It’s for two sites that connect via a VPN.
Thank you very much. This worked exactly as you described it.
Valuable information.