Skip to main content

Join A Domain

Joining a Windows Machine to a Domain


Author: bobbuilder


Prerequisites

  • A user account with permissions to join computers to the domain.
  • The domain name (e.g., targetdomain.com).
  • The domain controller's IP or hostname (optional, but useful for troubleshooting).
  • The machine must be able to reach the domain controller (DNS and network connectivity).
  • The machine must have the correct DNS settings pointing to the domain controller.

Join via GUI

  1. Open Settings (Win + I).
  2. Go to AccountsAccess work or school.
  3. Click ConnectJoin this device to a local Active Directory domain.
  4. Enter the domain name (e.g., targetdomain.com) and click Next.
  5. Provide domain credentials (e.g., DOMAIN\username or username@domain.com).
  6. Click OK and restart the computer when prompted.

join-domain-gui.png set_dns_windows_gui.png

Join via System Properties

  1. Open Run (Win + R), type sysdm.cpl, and press Enter.
  2. Go to the Computer Name tab and click Change.
  3. Under Member of, select Domain and enter the domain name (e.g., targetdomain.com).
  4. Click OK and enter domain credentials when prompted.
  5. Restart the computer to complete the domain join.

Join via PowerShell

Check Current Domain Status

Get-ComputerInfo | Select-Object CsDomain
Get-WmiObject Win32_ComputerSystem | Select-Object Domain

Verify DNS Settings

Ensure the domain name resolves to the correct Domain Controller (DC).

Get Domain's IP Address

nslookup targetdomain.com
Get-DnsClientServerAddress

Set the DNS Server to the Domain Controller

If DNS is not set correctly, update it.

Set on a Specific Interface

Find the correct interface:

Get-NetAdapter | Select-Object ifIndex, Name, InterfaceDescription, Status

Example Output:

ifIndex Name                         InterfaceDescription                 Status
------- ----                         --------------------                 ------
     13 OpenVPN Wintun               Wintun Userspace Tunnel              Disconnected
      8 OpenVPN TAP-Windows6         TAP-Windows Adapter V9               Disconnected
      7 Ethernet                     Intel(R) PRO/1000 MT Desktop Adapter Up
      6 OpenVPN Data Channel Offload OpenVPN Data Channel Offload         Up

Set the DNS server for the correct interface:

Set-DnsClientServerAddress -InterfaceIndex <ifIndex> -ServerAddresses ("<dc_ip>")

Or set it for a given Interface Name:

$interfID = (Get-NetAdapter | Where-Object { $_.InterfaceDescription -like "*<interface_name>*" } | Select-Object -ExpandProperty ifIndex)
Set-DnsClientServerAddress -InterfaceIndex $interfID -ServerAddresses ("<dc_ip>")
Set for All Interfaces
Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter | Select-Object -ExpandProperty ifIndex) -ServerAddresses ("<dc_ip>")
Reset DNS Settings (Undo Changes)
Set-DnsClientServerAddress -InterfaceIndex (Get-NetAdapter | Select-Object -ExpandProperty ifIndex) -ResetServerAddresses

(Not Recommended) Modify Hosts File

notepad C:\Windows\System32\drivers\etc\hosts

Join the Machine to a Domain

Add-Computer -DomainName "targetdomain.com" -Credential "targetdomain\admin" -Restart

join_domain_windows_powershell.png


Verifying Domain Membership

After restarting, verify the domain join status.

PowerShell

Get-WmiObject Win32_ComputerSystem | Select-Object Domain

Command Prompt

echo %userdomain%

Remove Computer From Domain

GUI

remove-from-domain-gui.png

PowerShell

Remove-Computer -UnjoinDomainCredential DOMAIN\Administrator -WorkgroupName WORKGROUP -Force -Restart