The simplest way to join a Windows server to an Active Directory domain—using PowerShell—requires just a few commands in an elevated prompt. You’ll need the server’s hostname, domain credentials, and basic network connectivity (DNS resolution and IP reachability). After running the command, the server becomes part of the domain, enabling access to resources, group policies, and security policies.
What You'll Need
- The server’s hostname (e.g., "SERVER01") and its local IP address.
- An account with domain admin or equivalent privileges (run PowerShell as Administrator).
- Network access to the domain controllers (verify DNS resolution with `nslookup domain.com`).
- Install the RSAT (Remote Server Administration Tools) package if joining via a non-domain-joined PC (e.g., a workstation).
- The target domain’s name (e.g., "contoso.com").
Step-by-Step
-
Open PowerShell as Administrator:
- Press
Win + Xand select Windows Terminal (Admin) or PowerShell (Admin). - If prompted, confirm elevation.
- Press
-
Install RSAT (if not already installed) on a non-domain-joined PC:
- On Windows 10/11 Pro/Enterprise, open
Settings > Apps > Optional Features. - Search for Remote Server Administration Tools, click Show, and install the Active Directory Domain Services Tools bundle.
- On Windows 10/11 Pro/Enterprise, open
-
Run the join command:
- Replace
DOMAINNAME,SERVERNAME, andADMIN_USERNAMEwith your values:Add-Computer -DomainName "DOMAINNAME" -Credential (New-Object System.Management.Automation.PSCredential ("ADMIN_USERNAME", (ConvertTo-SecureString -String "PASSWORD" -Force -AsPlainText))) -RestartExample:Add-Computer -DomainName "contoso.com" -Credential (New-Object System.Management.Automation.PSCredential ("admin", (ConvertTo-SecureString -String "P@ssw0rd" -Force -AsPlainText))) -Restart - If the server already has a local account, omit the
-Credentialparameter.
- Replace
-
Verify the join was successful:
- Run:
Get-ComputerInfo - Check for the Domain status in the output. If this fails, proceed to troubleshooting.
- Run:
Common Mistakes
- DNS resolution fails: Verify DNS servers in DNS client settings:
- Open
gpedit.msc, navigate to Computer Configuration > Windows Settings > Security Settings > Network Security > Local Policies > Security Options - Ensure Network path request timeout: 300 seconds is set.
- Open
- Network connectivity issues: Ping domain controllers (e.g.,
ping DOMAINNAME\DC01). If blocked, check firewall rules:- On the server, open
Windows Defender Firewall with Advanced Securityand allowDomainprofiles for TCP/UDP 389, 636, and 53.
- On the server, open
- Permission denied: Use a domain admin account with Read permissions on the domain controller’s
NTDS Settingsobject (via RSAT). - Restart required but not happening: Force a restart by adding
-Forceto the command, then manually reboot (e.g.,-Restartalready includes this).
Tips
- Use
Test-NetConnectionto check port reachability (e.g., 389 for LDAP). - For silent installation (no UI), omit the
-Restartparameter and run:Add-Computer -DomainName "DOMAIN" -Credential (New-Object ...), then manually restart the server. - Store credentials securely in
SecureStringto avoid hardcoding passwords in scripts. - If the server is already part of another domain, reset the join by running:
Remove-Computer -Disconnect -Restartfirst. - Use
Get-WindowsOptionalFeatureto confirm RSAT is installed and enable the AD DS Tools feature.
Troubleshooting
If the command fails:- General errors:
- Check PowerShell execution policy: Run
Set-ExecutionPolicy RemoteSignedif blocked. - Run
Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Microsoft-Windows-ServerManager'}to diagnose server-specific issues.
- Check PowerShell execution policy: Run
- DNS or Kerberos issues:
- Enable
ldap://andkerberos://Kerberos delegation in GPO if cross-domain delegation is needed. - Use
Test-NetConnectionto verify Kerberos ports (5349 for Kerberos).
- Enable
- Time synchronization:
- Sync time with a domain-joined PC or NTP server:
w32tm /configure /syncfromflags:manual /manualpeerlist:"DOMAIN\DC01" /reliable /update
- Sync time with a domain-joined PC or NTP server:
- Persistent errors:
- Reset the domain controller’s
NTDS.ditvia ADSI Edit (use a domain admin account) or restore from a backup. - Create a new domain controller if the original is compromised.
- Reset the domain controller’s
Frequently Asked Questions
Why does the join command fail even though I can ping the domain controller?
The issue is likely DNS resolution or port blocking. Verify LDAP (389) and Kerberos (5349) ports are open on the server’s firewall, and ensure DNS servers are correctly configured in C:\Windows\System32\drivers\etc\hosts (forcefully with Set-Item).
What if I don’t have admin credentials?
You cannot join a server to a domain without domain admin rights. Request credentials from a domain admin before attempting the command.
How long does a domain join take?
Typically 5–15 minutes, depending on server size and network latency. For large servers, use -Restart only if the command hangs.
Can I join a server to a non-local domain?
Yes, but network latency or security policies may require Test-NetConnection checks and explicit credentials. Test connectivity first with Test-Connection DOMAIN\DC01.
What happens if I join the wrong domain?
The server will fail to join and return an error like The specified domain either does not exist or could not be contacted. Correct the domain name or reset the command.
Do I need to disable a previous domain membership first?
If the server is already in another domain, run Remove-Computer -Disconnect -Restart first to avoid conflicts.