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

  1. Open PowerShell as Administrator:
    1. Press Win + X and select Windows Terminal (Admin) or PowerShell (Admin).
    2. If prompted, confirm elevation.
  2. Install RSAT (if not already installed) on a non-domain-joined PC:
    1. On Windows 10/11 Pro/Enterprise, open Settings > Apps > Optional Features.
    2. Search for Remote Server Administration Tools, click Show, and install the Active Directory Domain Services Tools bundle.
  3. Run the join command:
    1. Replace DOMAINNAME, SERVERNAME, and ADMIN_USERNAME with your values: Add-Computer -DomainName "DOMAINNAME" -Credential (New-Object System.Management.Automation.PSCredential ("ADMIN_USERNAME", (ConvertTo-SecureString -String "PASSWORD" -Force -AsPlainText))) -Restart Example: Add-Computer -DomainName "contoso.com" -Credential (New-Object System.Management.Automation.PSCredential ("admin", (ConvertTo-SecureString -String "P@ssw0rd" -Force -AsPlainText))) -Restart
    2. If the server already has a local account, omit the -Credential parameter.
  4. Verify the join was successful:
    1. Run: Get-ComputerInfo
    2. Check for the Domain status in the output. If this fails, proceed to troubleshooting.

Common Mistakes

  • DNS resolution fails: Verify DNS servers in DNS client settings:
    1. Open gpedit.msc, navigate to Computer Configuration > Windows Settings > Security Settings > Network Security > Local Policies > Security Options
    2. Ensure Network path request timeout: 300 seconds is set.
  • Network connectivity issues: Ping domain controllers (e.g., ping DOMAINNAME\DC01). If blocked, check firewall rules:
    1. On the server, open Windows Defender Firewall with Advanced Security and allow Domain profiles for TCP/UDP 389, 636, and 53.
  • Permission denied: Use a domain admin account with Read permissions on the domain controller’s NTDS Settings object (via RSAT).
  • Restart required but not happening: Force a restart by adding -Force to the command, then manually reboot (e.g., -Restart already includes this).

Tips

  • Use Test-NetConnection to check port reachability (e.g., 389 for LDAP).
  • For silent installation (no UI), omit the -Restart parameter and run: Add-Computer -DomainName "DOMAIN" -Credential (New-Object ...), then manually restart the server.
  • Store credentials securely in SecureString to avoid hardcoding passwords in scripts.
  • If the server is already part of another domain, reset the join by running: Remove-Computer -Disconnect -Restart first.
  • Use Get-WindowsOptionalFeature to confirm RSAT is installed and enable the AD DS Tools feature.

Troubleshooting

If the command fails:
  • General errors:
    1. Check PowerShell execution policy: Run Set-ExecutionPolicy RemoteSigned if blocked.
    2. Run Get-WinEvent -FilterHashtable @{LogName='Application'; ProviderName='Microsoft-Windows-ServerManager'} to diagnose server-specific issues.
  • DNS or Kerberos issues:
    1. Enable ldap:// and kerberos:// Kerberos delegation in GPO if cross-domain delegation is needed.
    2. Use Test-NetConnection to verify Kerberos ports (5349 for Kerberos).
  • Time synchronization:
    1. Sync time with a domain-joined PC or NTP server: w32tm /configure /syncfromflags:manual /manualpeerlist:"DOMAIN\DC01" /reliable /update
  • Persistent errors:
    1. Reset the domain controller’s NTDS.dit via ADSI Edit (use a domain admin account) or restore from a backup.
    2. Create a new domain controller if the original is compromised.

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.