Windows OS Hub
  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu
  • Home
  • About

Windows OS Hub

  • Windows Server
    • Windows Server 2022
    • Windows Server 2019
    • Windows Server 2016
    • Windows Server 2012 R2
    • Windows Server 2008 R2
    • SCCM
  • Active Directory
    • Active Directory Domain Services (AD DS)
    • Group Policies
  • Windows Clients
    • Windows 11
    • Windows 10
    • Windows 8
    • Windows 7
    • Windows XP
    • MS Office
    • Outlook
  • Virtualization
    • VMWare
    • Hyper-V
    • KVM
  • PowerShell
  • Exchange
  • Cloud
    • Azure
    • Microsoft 365
    • Office 365
  • Linux
    • CentOS
    • RHEL
    • Ubuntu

 Windows OS Hub / Active Directory / Join a Windows Computer to an Active Directory Domain

February 3, 2023 Active DirectoryQuestions and AnswersWindows 10Windows 11Windows Server 2022

Join a Windows Computer to an Active Directory Domain

This article describes how to join a Windows 10/11 or Windows Server 2022/2019/2016 computer to an on-premises Active Directory domain.

Contents:
  • Before You Join Windows to an AD Domain
  • Add Windows to the Domain Using System Properties GUI
  • Joining Windows to a Domain via the Settings App
  • How to Join a Computer to a Domain with PowerShell?
  • Pre-staging a Computer Accounts in Active Directory

Before You Join Windows to an AD Domain

First, let’s look at the basic requirements and preparations that you need to make on your computer before you join an Active Directory domain:

  • Only Pro, Education, Pro for Workstations, and Enterprise editions of Windows 10/11 can be joined to a domain. Note that the Active Directory domain is not supported in Home Editions;
  • Your device needs to be connected to a local network and able to access at least one AD domain controller. We assume that your computer already has an IP address from the local subnet configured, with the IP addresses of the nearest domain controllers specified in the computer’s DNS settings (you can configure the network adapter settings manually or get them from the DHCP server);
  • Make sure that your computer can resolve the domain name and can access the domain controller: ping woshub.loc use ping to check domain controller connectivity
  • The computer’s local time must be within five minutes of the domain controller’s time. The proper time synchronization is required for Kerberos authentication;
  • Set the name of your computer (hostname) to be used in a domain. By default, Windows generates a computer name during installation. However, it’s best to change it to something more meaningful. You can change the computer name using the classic Control Panel sysdm.cpl . Click Change, enter a new computer name, and press OK. As you can see, the computer is now a member of the default WORKGROUP); Change Windows hostname (computer name)
    You can also use the PowerShell command to change the computer name:
    Rename-Computer -NewName "wks-tst1"After you change the hostname, you must restart Windows.
    renam-computer with powershell

Add Windows to the Domain Using System Properties GUI

You can add your computer to the domain using the classic Control Panel in Windows:

  1. Run sysdm.cpl and click Change;
  2. Switch the Member of option to Domain and specify your domain’s name; join domain via system properties
  3. You will be prompted to enter the name and password of a user with delegated administrative AD permissions to join computers to the domain. This may be a regular AD user (by default, any domain user can join up to 10 devices) or a privileged domain administrator account; user credential to join active directory
  4. The next thing you should see is the message Welcome to the woshub.loc domain; Welcome to the domain
  5. Restart your computer.

To join a Windows Server 2022/2019/2019 computer to an AD domain, you must open the System Properties dialog box from the Server Manager -> Local Server -> Domain.

windows server manager join domain

On Windows Server Core, you can use the sconfig tool to join a host to a domain. See the article on how to configure the Server Core from the command prompt.

After the computer restarts, the domain Group Policies will be applied to your computer, and you will be able to sign in using your domain user account.

Joining Windows to a Domain via the Settings App

Newer versions of Windows 10 and Windows 11 let you join a computer to an AD domain from the Settings app panel.

  1. Go to Settings -> Accounts -> Access work or school -> and click Connect (for a quick jump to this Settings section, use the following URI shortcut command: ms-settings:workplace);
  2. Click the link below Alternate actions: Join this device to a local Active Directory domain; Windows Settings app -> Join this device to a local Active Directory domain
    If your computer has already been added to the domain, you will see a notification, e.g. “Connected to WOSHUB AD domain“. Windows device connected to AD domain
  3. Enter the domain name; specify an AD domain name to join
  4. Then specify a domain user credential;
  5. Skip the next step of adding the user to the Administrators group (you can add a user to the local Admins using  GPO);
  6. You need to restart Windows to complete joining the domain. restart your PC to compleate domain join

How to Join a Computer to a Domain with PowerShell?

To join computers to an Active Directory domain, you can use the Add-Computer Powershell cmdlet. You can use this command to join a domain with a new hostname and immediately move the computer’s account to a specific OU.

For the simplest case, adding to a domain requires one command only:

Add-Computer -DomainName woshub.loc

Then enter your username and password in the pop-up window.

Add-Computer - join computer to a domain

As mentioned earlier, you can immediately move your computer to a desired OU. In the -OUPath parameter, specify the target OU name in the distinguished name (DN) format:

$OU ="OU=Computers,OU=Munich,DC=woshub,DC=loc"
Add-Computer -DomainName woshub.loc -OUPath $OU -Restart

The -Restart option means that you want to restart Windows immediately after completing the Add-Computer command.

PowerShell: Adding a computer to a Delegated OU

Once the system has been restarted, you can verify that your computer is now a member of the Windows domain by running the command

Get-WmiObject Win32_NTDomain

This command returns the domain name, AD site name, IP address, and domain controller name used to log on (Logon server).

Get-WmiObject Win32_NTDomain - view domain info on a computer

You can also get your domain name with the command:

systeminfo | findstr /B "Domain"

systeminfo | findstr domain

You can also add a remote computer to the domain. To do this, you must specify the computer name in the -ComputerName parameter:

Add-Computer -ComputerName wks-mn14 -DomainName woshub.loc -Credential woshub\Administrator -LocalCredential wks-mn14\Admin -Restart –Force

This requires that the WinRM service is enabled and configured on the remote computer. Learn more about how to configure WinRM for PowerShell remoting on computers in a workgroup environment.

Note that the Add-Computer command is missing from the built-in Microsoft.PowerShell.Management module in the new versions of PowerShell Core 6.x and 7.x.

Add-Computer: The term 'Add-Computer' is not recognized as a name of a cmdlet, function, script file, or executable program.
Check the spelling of the name, or if a path was included, verify that the path is correct and try again.
Suggestion [4,General]: The most similar commands are: Add-Computer, Stop-Computer, Get-ADComputer, New-ADComputer, Set-ADComputer, Add-Content, Rename-Computer, Add-Member.

Therefore, use powershell.exe instead of pwsh.exe to add a computer to the domain in this case.

You can also use the netdom.exe tool to join Windows to a domain. However, it requires the installation of the RSAT administration package on the client’s computer and is now very rarely used.

netdom join %computername% /domain:woshub.loc /UserD:woshub\admin /PasswordD:paSS321

In order to remove a computer from an Active Directory domain and return it to a workgroup, run the following PowerShell command

Remove-Computer

After you leave the domain, you will need to know the password of the local Administrator account to log onto this computer. Do you wish to continue?
[Y] Yes [N] No [S] Suspend [?] Help (default is "Y"): y

Remove-Computer from AD

Pre-staging a Computer Accounts in Active Directory

By default, when you join new computers to a domain, they are placed in the built-in Computers container in the domain root. To manually move a computer account to a different OU (Organizational Unit), you can either drag and drop it or use the Move menu item.

move ad computer object to another ou

Ad administrator can pre-stage a computer account in Active Directory via the Active Directory Users and Computers dsa.msc snap-in (New -> Computer) or with the New-ADComputer cmdlet from the ActiveDirectory PowerShell module:

New-ADComputer -Name "wks-mn14" -SamAccountName "wks-mn14" -Path "OU=Computers,OU=Munich,DC=woshub,DC=loc"

When you manually create a computer account, make sure that the name you specify matches the hostname of the computer you are adding to the AD domain.

We recommend that you first perform an AD search for computers with the same name. If this name is already in use and you want to assign it to another computer, a solution would be to reset it. Right-click on the computer in AD and select Reset Account.

Reset computer account in Active Directroy

One more way to reset a computer account in AD is to use PowerShell

Get-ADComputer -Identity "computername" | % {dsmod computer $_.distinguishedName -reset}

This resets the domain computer password used to establish a trust relationship with AD.

0 comment
1
Facebook Twitter Google + Pinterest
previous post
Using Previous Command History in PowerShell Console
next post
Disable Built-in PDF Viewer in Microsoft Edge

Related Reading

Zabbix: How to Get Data from PowerShell Scripts

October 27, 2023

Tracking Printer Usage with Windows Event Viewer Logs

October 19, 2023

How to Use Ansible to Manage Windows Machines

September 25, 2023

Installing Language Pack in Windows 10/11 with PowerShell

September 15, 2023

How to View and Change BIOS (UEFI) Settings...

September 13, 2023

Leave a Comment Cancel Reply

Categories

  • Active Directory
  • Group Policies
  • Exchange Server
  • Microsoft 365
  • Azure
  • Windows 11
  • Windows 10
  • Windows Server 2022
  • Windows Server 2019
  • Windows Server 2016
  • PowerShell
  • VMWare
  • Hyper-V
  • Linux
  • MS Office

Recent Posts

  • Zabbix: How to Get Data from PowerShell Scripts

    October 27, 2023
  • Tracking Printer Usage with Windows Event Viewer Logs

    October 19, 2023
  • PowerShell: Configure Certificate-Based Authentication for Exchange Online (Azure)

    October 15, 2023
  • Reset Root Password in VMware ESXi

    October 12, 2023
  • How to Query and Change Teams User Presence Status with PowerShell

    October 8, 2023
  • How to Increase Size of Disk Partition in Ubuntu

    October 5, 2023
  • How to Use Ansible to Manage Windows Machines

    September 25, 2023
  • Installing Language Pack in Windows 10/11 with PowerShell

    September 15, 2023
  • Configure Email Forwarding for Mailbox on Exchange Server/Microsoft 365

    September 14, 2023
  • How to View and Change BIOS (UEFI) Settings with PowerShell

    September 13, 2023

Follow us

  • Facebook
  • Twitter
  • Telegram
Popular Posts
  • Configure Google Chrome Settings with Group Policy
  • Allow Non-admin Users RDP Access to Windows Server
  • How to Find the Source of Account Lockouts in Active Directory
  • How to Disable or Enable USB Drives in Windows using Group Policy
  • Get-ADComputer: Find Computer Properties in Active Directory with PowerShell
  • Refresh AD Groups Membership without Reboot/Logoff
  • How to Automatically Fill the Computer Description in Active Directory
Footer Logo

@2014 - 2023 - Windows OS Hub. All about operating systems for sysadmins


Back To Top