If you try to rename an Active Directory domain controller the way you rename domain member computers/servers (by using the sysdm.cpl
console or the Rename-Computer
PowerShell cmdlet)), a warning will appear:
Domain controllers cannot be moved from one domain to another, they must first be demoted. Renaming this domain controller may cause it to become temporarily unavailable to users and computers. For information on renaming domain controllers, including alternate renaming methods, see Renaming a Domain Controller (http://go.microsoft.com/fwlink/?LinkID=177447). To continue renaming this domain controller, click OK.
This doesn’t mean that it is not possible to change the name of the domain controller. In this article, we will show you how to correctly rename an Active Directory domain controller running Windows Server 2019 from dc2 to hq-dc02.
Preparation for Active Directory Domain Controller Renaming
You can rename the domain controller if:
- Your forest uses at least the Windows Server 2003 domain functional level;
- There is at least one additional healthy DC in the domain;
- The DC must not have the Certification Authority role installed;
- Your account is added to the Domain Admins security group.
It is assumed that you have a minimum of two domain controllers that are deployed in your domain. If you only have one healthy domain controller, we recommend that you deploy an additional DC.
Check to see if the Flexible Single-Master Operation (FSMO) roles are running on the domain controller that you want to rename:
netdom query fsmo
If your DC is on this list, use the Move-ADDirectoryServerOperationMasterRole PowerShell cmdlet to move its FSMO roles to another domain controller (for example, to hq-dc01).
Move-ADDirectoryServerOperationMasterRole -Identity hq-dc01 -OperationMasterRole SchemaMaster, RIDMaster
In this example we have migrated 2 FSMO roles to hq-dc01. You can specify other FSMO roles in this command: PDCEmulator, InfrastructureMaster, DomainNamingMaster.
We also recommend that you back up your domain controller before changing the name (you can back up the DC using the built-in Windows Server Backup role).
How to Rename an AD Domain Controller using Netdom?
Open the elevated command prompt on the domain controller and add an alternate name to your DC:
netdom computername dc2.contoso.com /add:hq-dc02.contoso.com
Open the Active Directory Users and Computers console (run the dsa.msc
command), expand the Domain Controllers container find the domain controller account, and open its properties. Go to the Attribute Editor tab and check that the new DC name appears in the msDS-AdditionalDnsHostName attribute.
The netdom command must also register an A record for the new domain controller name in DNS. If the A record does not appear, run the command:
ipconfig /registerdns
Your computer will re-register itself on DNS.
Before proceeding to the next step, wait for the new records to be replicated throughout the domain.
If you want to start replicating immediately, run the command:
repadmin /syncall
The next step is to make the new DC name the primary DC name:
netdom computername dc2.contoso.com /makeprimary:hq-dc02.contoso.com
Successfully made hq-dc02.contoso.com the primary name for the computer. The computer must be rebooted for this name change to take effect. Until then this computer may not be able to authenticate users and other computers, and may not be authenticated by other computers in the forest. The specified new name was removed from the list of alternate computer names. The primary computer name will be set to the specified new name after the reboot.
The command completed successfully.
Reboot the domain controller.
In the Attribute Editor, check that the domain controller now has a primary name of hq-dc02 and that dc2 has become a secondary.
Open the DNS Manager console, select the domain you want, and expand the _msdcs branch. Check that the domain controller’s SRV records have been updated in all _msdscs subsections. If there is an NS entry for the old DC name, rename it.
Now you can remove the old name with the command:
netdom computername hq-dc02.contoso.com /remove: dc2.contoso.com
Make sure that there is only one name left for the server:
netdom computername hq-dc02.contoso.com /enumerate
You can remove the A record of the old domain controller in the DNS zone with the command:
dnscmd hq-dc02.contoso.com /recorddelete contoso.com dc2 A /f
Also manually remove the old DC name in the msDS-AdditionalDnsHostName attribute of the domain controller with the ADUC snap-in.
After changing the domain controller name, you need to update the domain controller name in the Distributed File System (DFS) or File Replication Service (FRS) Replication member object. If you don’t do this, your DC won’t be able to replicate the SYSVOL directory.
Switch to the ADUC console and go to System -> DFSR-GlobalSettings -> Domain System Volume -> Topology (if this section is not displayed, enable the Advanced Features option in the View menu). Find the msDFSR-Member object with the old name and rename it.
Open the ADSIEdit.msc
snap-in, snap-in, expand the new domain controller object in OU=Domain Controller. Check that the DFSR-LocalSettings object now has the new DC name in its msDFSR-MemberReference attribute.
Check the value of the SysvolReady attribute on the domain controller in the HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters
registry key. Change its value to 1 and wait for AD replication to complete.
Check the domain controller logs and run the dcdiag
command to check that ADDS is working correctly.
Renaming a domain controller in this way leaves an SPN in the DC account. This SPN is not automatically removed. You will get an error if you try to use this SPN in a domain:
The operation failed because SPN value provided for addition/modification is not unique forest-wide.
To remove an old SPN entry, execute:
setspn -l dc2.contoso.com
You can also manually rename the domain controller from the registry. However, we do not recommend this method (!!!) The name of the computer is stored in the following keys in the Windows registry:
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname
Переименовать компьютер просто — достаточно зайти в его свойства, сменить имя и перезагрузиться. Но если компьютер является контроллером домена, то все становиться несколько сложнее.
При попытке изменить подобным способом имя на контроллере домена вы получите предупреждение о том, что переименование может отрицательно повлиять на работу пользователей в домене. Действительно, изменения в доменной среде происходят не мгновенно и после переименования пользователи могут некоторое время обращаться к контроллеру по старому имени. В результате могут возникать ошибки авторизации, отказы в доступе к ресурсам и прочие неприятности. Избежать всего этого можно с помощью альтернативной процедуры переименования, предназначенной специально для контроллеров домена.
Мы с вами рассмотрим эту процедуру на примере сервера SRV2, который будет переименован в DC2.
Перед тем, как приступать к переименованию, надо соблюсти ряд условий:
• В домене должен быть еще как минимум один работоспособный контроллер домена;
• Функциональный уровень домена должен быть не ниже Windows Server 2003;
• На сервере не должно быть установлено роли центра сертификации (Certification Authority);
Если все условия выполнены, то можно приступать к переименованию. Для этого нам потребуется утилита командной строки NETDOM. Изначально эта утилита входила в состав Windows Server 2003 Support Tools, а начиная с Windows Server 2008 ее добавили непосредственно в операционную систему и она по умолчанию есть на любом сервере с ОС Windows Server.
Запускать утилиту не обязательно на том контроллере домена, который будет переименован, можно использовать любой доменный компьютер. Но пользователь, от имени которого производится переименование, обязательно должен входить в группу администраторов домена (Domain Admins).
На первом шаге откроем командную консоль и выполним команду:
netdom computername srv2.test.local /add:dc2.test.local
Эта команда добавит серверу дополнительное доменное имя и зарегистрирует его в DNS. Для проверки откроем оснастку ADSIEdit и в свойствах сервера найдем атрибут msDS-AdditionalDnsHostName. Именно в этом атрибуте должно быть прописано новое имя.
Дополнительно заглянем в DNS и убедимся в наличии новой записи.
Теперь сделаем новое имя основным. Для этого выполним команду:
netdom computername srv2.test.local /makeprimary:dc2.test.local
Обратите внимание, что для применения изменений необходима перезагрузка сервера.
После перезагрузки произойдет смена имени. Для проверки откроем ADSIEdit и убедимся в том, что имя DC2 стало основным, а SRV2 — дополнительным.
Поскольку старое имя SRV2 нам больше не нужно, окончательно удалим его командой:
netdom computername dc2.test.local /remove:srv2.test.local
Имя сервера успешно изменено, но это еще не все. После переименования контроллера домена требуется обновить Distributed File System (DFS) или File Replication Service (FRS) Replication member object. Этот объект необходимо обновить с новым именем для того, чтобы контроллер смог реплицировать папку SYSVOL.
Для этого открываем оснастку Active Directory Users and Computers и в меню View отмечаем пункт Advanced Features.
Затем переходим в раздел System -> DFSR-GlobalSettings -> Domain System Volume -> Topology, находим объект msDFSR-Member со старым именем и переименовываем его.
Для проверки можно снова воспользоваться ADSIEdit. Надо найти объект DFSR-LocalSettings и убедиться в том, что у него в атрибуте msDFSR-MemberReference указано новое имя сервера.
На этом переименование закончено, остается только убедиться в том, что изменения реплицировались на все контроллеры домена.
Ну и в завершение.
При попытке добавить имя столкнулся с такой ошибкой: ″The specified domain either does not exist or could not be contacted″.
Как удалось выяснить, такая проблема может возникнуть при отсутствии на контроллере домена общего доступа к папке SYSVOL. Для избавления от ошибки надо в реестре, в разделе HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters найти параметр SysvolReady и задать ему значение 1.
После этого ошибка ушла и все команды отработали без проблем.
При попытке переименовать контроллер домена Active Directory так, как вы обычно переименовываете рядовые рабочие станции/сервера домена (через консоль sysdm.cpl
или с помощью PowerShell командлета Rename-Computer
), появится предупреждение:
Domain controllers cannot be moved from one domain to another, they must first be demoted. Renaming this domain controller may cause it to become temporarily unavailable to users and computers. For information on renaming domain controllers, including alternate renaming methods, see Renaming a Domain Controller (http://go.microsoft.com/fwlink/?LinkID=177447). To continue renaming this domain controller, click OK.
Это не значит, что изменить имя контроллера домена невозможно. В этой статье мы покажем, как корректно переименовать контроллер домена Active Directory с dc2 в msk-dc02.
Подготовка к переименованию контроллера домена Active Directory
Вы можете переименовать контроллер домена, если:
- Функциональный уровень домена не ниже Windows Server 2003;
- В домене есть как минимум один работоспособный DC;
- На DC не должна быть установлена роль Certification Authority;
- Ваша учетна запись добавлена в доменную группу Domain Admins.
Мы подразумеваем, что в вашем домене развернуто как минимум два контроллера домена. Если у вас только один DC, рекомендует развернуть еще один дополнительный контроллер домена.
Проверьте, запущены ли роли FSMO (Flexible Single-Master Operation) на котроллере домена, который вы хотите переименовать:
netdom query fsmo
Если в этом списке есть ваш DC, перенесите его FSMO роли на другой контроллер домена (например на msk-dc01) с помощью PowerShell командлета Move-ADDirectoryServerOperationMasterRole.
Move-ADDirectoryServerOperationMasterRole -Identity msk-dc01 -OperationMasterRole SchemaMaster, RIDMaster
В этом примере мы перенесли 2 FSMO роли msk-dc01. Можно указать в этой команде и другие роли: PDCEmulator, InfrastructureMaster, DomainNamingMaster.
Также рекомендуем создать резервную копию вашего контроллера домена перед сменой имени (можно создать резервную копию DC с помощью встроенной роли Windows Server Backup).
Изменить имя контроллера домена AD с помощью Netdom
Запустите на контроллере домена командную сроку и добавьте дополнительное имя вашему DC:
netdom computername dc2.contoso.com /add:msk-dc02.contoso.com
Формат команды:
netdom computername OldDCName /add:NewDCName
Указывайте FQDN имена.
Откройте консоль Active Directory Users and Computers (команда dsa.msc), разверните контейнер Domain Controllers, найдите учетную запись вашего контроллера домена и откройте его свойства. Перейдите на вкладку Attribute Editor и проверьте, что новое имя DC появилось в атрибуте msDS-AdditionalDnsHostName.
Команда netdom также должна зарегистрировать A запись для нового имени контроллера домена в DNS. Если A запись не появилась, выполните команду:
ipconfig /registerdns
Ваш компьютер повторно пропишет себя на DNS серверах.
Дождитесь окончания репликации новых записей по всему домену прежде чем переходить к следующему шагу.
Можно запустить немедленною репликацию с помощью команды:
repadmin /syncall
Теперь нужно сделать новое имя основным:
netdom computername dc2.contoso.com /makeprimary: msk-dc02.contoso.com
Successfully made msk-dc02.contoso.com the primary name for the computer. The computer must be rebooted for this name change to take effect. Until then this computer may not be able to authenticate users and other computers, and may not be authenticated by other computers in the forest. The specified new name was removed from the list of alternate computer names. The primary computer name will be set to the specified new name after the reboot. The command completed successfully.
Перезагрузите контроллер домена.
Проверьте в редакторе атрибутов, что у контроллера домена теперь основное имя msk-dc02, а dc2 стало дополнительным.
Откройте консоль DNS Manager, выберите ваш домен и разверните папку _msdcs. проверьте, что SRV записи контроллера домена были обновлены во всех сервисных секциях _msdscs. Если здесь присутствует NS запись для старого имени DC, переименуйте ее.
Также можно удалить A запись старого контроллера домена с помощью команды:
dnscmd msk-dc02.contoso.com /recorddelete contoso.com dc2 A /f
Теперь можно удалить старое имя командой:
netdom computername msk-dc02.contoso.com /remove: dc2.contoso.com
Проверьте, что у сервера осталось только одно имя:netdom computername msk-dc02.contoso.com /enumerate
Также в оснастке ADUC вручную удалите старое имя DC в атрибуте msDS—AdditionalDnsHostName контроллера домена.
После смены имени контроллера домена нужно обновить имя контроллера домена в объекте Distributed File System (DFS) или File Replication Service (FRS). Если это не сделать, ваш DC не сможет реплицировать каталог SYSVOL.
Откройте консоль ADUC и перейдите в раздел System -> DFSR-GlobalSettings -> Domain System Volume -> Topology (если этот раздел не отображается включите опцию Advanced Features в меню View). Найдите объект msDFSR-Member со старым именем и переименуйте его.
Запустите консоль ADSIEdit, разверните новый контроллер домена в OU=Domain Controller. Проверьте, что у объекта DFSR-LocalSettings в атрибуте msDFSR-MemberReference теперь указано новое имя DC.
Проверьте значение атрибута SysvolReady на контроллере домена в ветке HKLM\SYSTEM\CurrentControlSet\Services\Netlogon\Parameters. Измените его значение на 1 и дождитесь окончания репликации AD.
Проверьте логи контроллера домена и выполните команду dcdiag
чтобы проверить, что ADDS работает корректно.
При переименовании контроллера домена таким образом, в учетной записи DC остается SPN, который не будет удален автоматически. Если вы попробуете использовать это имя в домене, появится ошибка:
The operation failed because SPN value provided for addition/modification is not unique forest-wide.
Чтобы удалить старую SPN запись, выполните:
setspn -l dc2.contoso.com
Также можно вручную переименовать контроллер домена из реестра. Но этот способ не рекомендуется!!! Имена компьютера хранятся в следующих разделах реестра Windows:
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ActiveComputerName\ComputerName
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\ComputerName\ComputerName\ComputerName
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\Hostname
- HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters\NV Hostname
Не редко бывают ситуации в которых необходимо переименовать контроллер домена Active Directory Domain Controller.
Как это работает можно почитать у мелкомягких
How Domain Rename Works
Как это можно просто и безболезненно сделать в продакшене подробно описано на сайте
THE ICT GUY за что им отдельное спасибо!
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
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
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
Tags: Server 2019, Active Directory, Active Directory server configuration, Active Directory server maintenance, Active Directory server modification, Active Directory server name update, Active Directory server update, can i rename a domain controller, can you rename a domain controller, change domain controller name, change name domain controller, Domain controller name modification, domain controller rename, Domain server renaming, how to rename a domain controller, how to rename domain controller, Netdom command usage, Netdom rename command, Netdom rename command usage, Netdom rename process, Netdom rename process explained, Netdom rename utility, Netdom server name change, Netdom server name modification, Netdom server rename, Netdom server rename process, Netdom utility for renaming, Netdom utility for server renaming, rename a domain, Rename a domain controller, rename ad domain, rename dc, rename domain, rename domain computer command line, rename domain controller, rename domain controller 2012, rename domain controller 2019, rename domain controller computer name, rename domain controller netdom, rename server 2022 dc, Rename server 2022 domain controller, renaming a domain controller, renaming a domain controller 2003, renaming a domain controller 2008, renaming a domain controller 2008 R2, renaming a domain controller 2016, renaming domain controller, renaming domain controller 2019, Renaming domain controller in Windows, Renaming domain controller server, Renaming domain controller using netdom, Renaming domain controller with netdom, Renaming server in Windows, Renaming server using netdom, Renaming server with netdom utility, Renaming Windows domain controller, Renaming Windows server, Renaming Windows server using netdom, Server 2016, Server 2022, Server Guide, Server Migration, Server name alteration, Server name change, Server name migration, Server name migration process, Server name modification, Server name modification guide, Server name modification steps, Server name transformation, Server name transformation guide, Server name update, Server name update steps, Server renaming process, Windows Active Directory, Windows Server, Windows server administration, Windows server management, Windows server management tutorial, Windows server name change, Windows server rename, Windows server renaming guide, Windows server renaming tutorial