Install Active Directory Domain Services on Windows Server
Install the AD DS role, create a forest and promote a first domain controller with DNS on Windows Server, without exposing Active Directory ports to the Internet.
On this page
Your values
Enter them once and the commands in this guide update.
This guide walks you through creating a new domain: installing the Active Directory Domain Services (AD DS) role, promoting the server to the first domain controller of a new forest, configuring DNS, and then verifying the result. It applies to Windows Server 2019, 2022 and 2025, on a dedicated server as well as on a VPS.
Interface labels are given in English. They may differ if your Windows uses another display language.
Prerequisites
- A server running Windows Server 2019, 2022 or 2025, with the Desktop Experience, sized according to the hardware requirements.
- A server dedicated to this role: do not host a website, a game server or any other public service on it.
- A session opened with the built-in local Administrator account. Microsoft requires this to create a new forest.
- A fallback access that does not depend on RDP, tested before you start: the VNC console of the management panel for a VPS, or IP KVM access for a dedicated server.
- A domain name that you own, from which to derive the internal name.
- A VPN or a private network to connect your machines to the controller. Setting it up is not covered here.
Choose the domain name
Do not choose the forest name lightly, because it stays in place for the whole life of the directory. Microsoft recommends a registered DNS name, with a dedicated prefix that is not used anywhere else:
| Item | Example | Rule |
|---|---|---|
| Domain DNS name | corp.your-domain.com |
Subdomain of a name you own, reserved for Active Directory |
| NetBIOS name | CORP |
15 characters maximum |
Avoid single-label names (corp) and unregistered suffixes such as .local, which Microsoft discourages.
Prepare the server
Open PowerShell as administrator for all the commands in this guide.
1. Check the Windows edition
DISM /online /Get-CurrentEditionIf the edition name contains Eval, convert it before the promotion: Microsoft states that a domain controller cannot be moved from an evaluation version to a retail version. See managing your license and Microsoft's conversion procedure.
2. Rename the server
Give the server its final name now: renaming it after the promotion is much trickier.
Rename-Computer -NewName 'DC01' -Restart3. Note the network settings
Get-NetIPConfiguration
Get-NetIPInterface -AddressFamily IPv4 -ConnectionState Connected | Format-Table InterfaceAlias, DhcpWrite down the IP address, prefix, gateway and DNS servers of the main interface. You will need them if something goes wrong.
A domain controller must keep a fixed address. If Dhcp is Enabled on the main interface, switch it to manual configuration with exactly the same values, as described in the IP configuration guide.
4. Check the Administrator account
When the forest is created, the local Administrator account becomes the domain Administrator and keeps its password. This password cannot be blank and must be strong.
Get-LocalUser | Where-Object { $_.SID -like '*-500' } | Format-Table Name, EnabledTo change it, replace Administrator with the name displayed, then enter the new password at the prompt:
net user Administrator *5. Check the RDP firewall rule
After the promotion, the network adapter normally switches to the Domain firewall profile. An RDP rule limited to the Public or Private profiles would no longer apply, and you would lose access.
$rdpPort = (Get-ItemProperty 'HKLM:\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\RDP-Tcp').PortNumber
"RDP port: $rdpPort"
Get-NetFirewallPortFilter -Protocol TCP |
Where-Object { $_.LocalPort -contains "$rdpPort" } |
Get-NetFirewallRule |
Where-Object { $_.Direction -eq 'Inbound' -and $_.Enabled -eq 'True' } |
Format-Table Name, DisplayName, Profile, ActionThe rule that allows your connection must show Any or include Domain in the Profile column. If it does not, extend it using the name shown in the Name column:
Set-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP' -Profile AnyBlock the Active Directory ports on the public interface
Do this step before installing the role. An explicit block rule takes precedence over allow rules, so it stays effective whatever rules AD DS and DNS add. It only targets the public interface, which lets traffic arriving through a VPN or a private interface through.
First, identify the public interface:
$publicNic = (Get-NetIPConfiguration | Where-Object { $_.IPv4DefaultGateway }).InterfaceAlias
$publicNicThe command must display a single name, for example Ethernet. If it displays several, set the variable yourself: $publicNic = 'Ethernet'.
$tcpPorts = '53','88','135','139','389','445','464','636','3268','3269','9389','49152-65535'
$udpPorts = '53','88','123','137','138','389','464'
New-NetFirewallRule -Name 'AD-Block-Public-TCP' -DisplayName 'AD - Block public interface (TCP)' `
-Direction Inbound -Action Block -Profile Any -InterfaceAlias $publicNic -Protocol TCP -LocalPort $tcpPorts
New-NetFirewallRule -Name 'AD-Block-Public-UDP' -DisplayName 'AD - Block public interface (UDP)' `
-Direction Inbound -Action Block -Profile Any -InterfaceAlias $publicNic -Protocol UDP -LocalPort $udpPortsThese rules have no complete equivalent in the graphical interface, which lets you choose an interface type but not a specific interface. You can still find them in Windows Defender Firewall with Advanced Security, under Inbound Rules.
If your plan offers a firewall that can be configured from the console, you can add the same filtering there as a complement.
Install the AD DS role
With Server Manager
- Open Server Manager, then Manage > Add Roles and Features.
- On Before you begin, click Next.
- Choose Role-based or feature-based installation.
- Select your server from the pool.
- Check Active Directory Domain Services, then accept Add Features.
- Move on to the confirmation page and click Install.
This role does not require a restart at this stage. Leave the window open for the next step.
With PowerShell
Install-WindowsFeature -Name AD-Domain-Services -IncludeManagementToolsPromote the server to a domain controller
With the wizard
- When the role installation finishes, click Promote this server to a domain controller. If you closed the window, the link is under the notification flag in Server Manager.
- On Deployment Configuration, choose Add a new forest and enter
corp.your-domain.comas the root domain name. - On Domain Controller Options, leave DNS server checked, keep the proposed functional levels and enter the DSRM password.
- On DNS Options, do not check the delegation update. The warning shown here is normal.
- On Additional Options, check the NetBIOS name, for example
CORP. - On Paths, keep the default locations. Do not place these folders on a ReFS volume.
- Check the summary on Review Options.
- On Prerequisites Check, wait for the checks to finish, read the warnings, then click Install.
With PowerShell
First run the checks, which change nothing:
Test-ADDSForestInstallation -DomainName 'corp.your-domain.com' -DomainNetbiosName 'CORP' -InstallDns -CreateDnsDelegation:$falseIf the result is Success, create the forest. The command asks for the DSRM password, then for a confirmation:
Install-ADDSForest -DomainName 'corp.your-domain.com' -DomainNetbiosName 'CORP' -InstallDns -CreateDnsDelegation:$falseReconnect after the promotion
Wait a few minutes, then reconnect over RDP with the domain account and the password of the former local Administrator:
CORP\AdministratorOn a French-language Windows, the account may be called CORP\Administrateur. If RDP does not respond, use the VNC or IP KVM console and see troubleshooting.
Configure DNS
The DNS role is installed and the domain zone is integrated with Active Directory. The server now uses its own loopback address as its preferred DNS.
Get-DnsClientServerAddress -AddressFamily IPv4 | Format-Table InterfaceAlias, ServerAddresses
Get-DnsServerZone | Format-Table ZoneName, ZoneType, IsDsIntegratedResolve Internet names
For names outside your domain, the DNS server queries its forwarders. Check the ones it kept from the previous configuration:
Get-DnsServerForwarderIf the list is empty, add the resolvers you noted earlier, or public resolvers:
Add-DnsServerForwarder -IPAddress 1.1.1.1, 9.9.9.9 -PassThruIn the graphical interface, open DNS Manager, right-click the server, then Properties > Forwarders.
Rules to follow
- Domain machines must use only the private address of the controller as their DNS server. A public resolver would prevent them from finding the domain.
- Do not publish
corp.your-domain.comin the public DNS zone of your domain. - If the server also has a private interface, prevent its public address from being registered in the domain DNS, otherwise clients will try to reach it. Replace
Ethernetwith the name of your public interface:
Set-DnsClient -InterfaceAlias 'Ethernet' -RegisterThisConnectionsAddress $false
ipconfig /registerdnsIn that case, also limit the DNS service to listening on the private address, from DNS Manager > Properties > Interfaces. Microsoft describes this scenario in its article on multihomed domain controllers.
Verify the installation
On the server:
Get-ADForest | Format-List Name, ForestMode, RootDomain
Get-ADDomain | Format-List DNSRoot, NetBIOSName, DomainMode, PDCEmulator
Get-Service ADWS, DNS, DFSR, Kdc, Netlogon, NTDS | Format-Table Name, Status
Get-SmbShare -Name NETLOGON, SYSVOL
Resolve-DnsName -Name _ldap._tcp.dc._msdcs.corp.your-domain.com -Type SRV
dcdiagThe services must be in the Running state, the NETLOGON and SYSVOL shares must be present, and dcdiag must not report any failure. The SYSVOL share can take a few minutes to appear after the first boot.
From a Windows machine outside the server, check that only your administration access responds:
foreach ($port in 53, 88, 135, 389, 445, 636, 3268, 9389) {
$result = Test-NetConnection YOUR_SERVER_IP -Port $port -WarningAction SilentlyContinue
'{0,-5} {1}' -f $port, $result.TcpTestSucceeded
}
Test-NetConnection YOUR_SERVER_IP -Port 3389 -WarningAction SilentlyContinue | Select-Object TcpTestSucceeded
Resolve-DnsName -Name www.microsoft.com -Server YOUR_SERVER_IP -DnsOnlyEach Active Directory port must show False, the RDP port True, and the DNS query must fail. If a port responds, do not connect any machine before you have fixed the filtering. Adjust 3389 if you use a different RDP port.
Harden the server
Restrict RDP to your IP address
Set-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP', 'RemoteDesktop-UserMode-In-UDP' -RemoteAddress YOUR_IPThis command targets the standard Windows RDP rules. If you use a custom rule, apply the same restriction to it.
Create a named administration account
Avoid using the built-in Administrator account day to day. The group is looked up by its identifier, because its name depends on the Windows language:
$password = Read-Host 'Password' -AsSecureString
New-ADUser -Name 'adm.firstname' -SamAccountName 'adm.firstname' -UserPrincipalName 'adm.firstname@corp.your-domain.com' -AccountPassword $password -Enabled $true
$domainAdmins = Get-ADGroup -Identity "$((Get-ADDomain).DomainSID.Value)-512"
Add-ADGroupMember -Identity $domainAdmins -Members 'adm.firstname'Test this account in a new RDP session before closing the current one.
Back up the directory
Back up the system state to a separate volume, here E::
Install-WindowsFeature -Name Windows-Server-Backup
wbadmin start systemstatebackup -backupTarget:E: -quietMicrosoft advises against relying on virtual machine snapshots for a domain controller. On a VPS, do not treat them as your directory backup. Also copy the backups off the server.
Best practices
- Do not use a web browser on the domain controller.
- Install security updates regularly.
- Plan for a second domain controller: with only one, its failure makes the whole domain unavailable.
Troubleshooting
The promotion logs are in C:\Windows\debug\dcpromoui.log and C:\Windows\debug\dcpromo.log.
The local Administrator password is rejected
The prerequisites check fails, with code 94 in PowerShell:
Local admin password doesn't meet requirement: either blank or not requiredSet a strong password with net user Administrator *, then run the check again.
DNS delegation warning
A delegation for this DNS server can't be created because the authoritative parent zone can't be found or it doesn't run Windows DNS server.This message is harmless here: your internal zone does not need to be delegated from the public DNS.
Static IP address warning
The wizard reports that a physical network adapter has no static IP address. Redo step 3 from the console, then run the checks again.
RDP no longer responds after the promotion
The first boot can be long. After a few minutes, open the VNC or IP KVM console, sign in with the domain account, then check the network profile and the RDP rules:
Get-NetConnectionProfile | Format-Table InterfaceAlias, NetworkCategory
Get-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-*' | Format-Table Name, Enabled, Profile
Enable-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP', 'RemoteDesktop-UserMode-In-UDP'
Set-NetFirewallRule -Name 'RemoteDesktop-UserMode-In-TCP', 'RemoteDesktop-UserMode-In-UDP' -Profile AnyThe RDP connection rejects your credentials
Enter the account in the form CORP\Administrator, and delete the saved credentials for this server in your RDP client. If another account gets this message, it does not have the right to sign in remotely on a domain controller:
To sign in remotely, you need the right to sign in through Remote Desktop Services.The SYSVOL or NETLOGON shares are missing
Wait a few minutes after startup, then run the targeted tests and check the replication log:
dcdiag /test:sysvolcheck /test:advertising
Get-WinEvent -LogName 'DFS Replication' -MaxEvents 20 | Format-Table TimeCreated, Id, LevelDisplayNameInternet names no longer resolve on the server
Check the forwarders, then query the local DNS service directly:
Get-DnsServerForwarder
Resolve-DnsName -Name www.microsoft.com -Server 127.0.0.1A workstation cannot find the domain
An Active Directory Domain Controller (AD DC) for the domain "corp.your-domain.com" could not be contacted.The workstation must go through your VPN or private network, and its only DNS server must be the private address of the controller. Then test:
Resolve-DnsName -Name _ldap._tcp.dc._msdcs.corp.your-domain.com -Type SRVTime or Kerberos authentication error
Kerberos requires clocks to be close to each other. If you see a message indicating a time difference between the client and the server, check the controller's time source, then synchronize it with NTP servers:
w32tm /query /status
w32tm /config /manualpeerlist:"0.pool.ntp.org 1.pool.ntp.org" /syncfromflags:manual /reliable:yes /update
Restart-Service w32time
w32tm /resync