customer relationships

How to Add Computers to a Domain Using PowerShell

Performing a Domain Join Using PowerShell

Once you’ve established correct DNS resolution for the domain name, start a PowerShell prompt with local administrative privileges.

  • Press the Windows key to switch to the Start menu, type PowerShell and press CTRL+SHIFT+ENTER. If prompted, enter a local administrator username and password, or give consent to run PowerShell.
  • In the PowerShell prompt, type add-computer –domainname ad.contoso.com -Credential AD\adminuser -restart –force and press Enter. Enter a password for the domain administrator account when prompted.

The PC should now restart and be joined to the domain once it has restarted.

Add a computer to a domain using PowerShell
Add a computer to a domain using PowerShell.

Join Multiple PCs to a Domain

You can add more than one computer to the domain, either by using names from a text file or listing them in the command line as a comma-delimited list. You can use the –computername parameter even if PowerShell Remoting isn’t enabled on the computers listed in the command line.

  • In a PowerShell command prompt, type add-computer -computername srvcore01, srvcore02 -domainname ad.contoso.com –credential AD\adminuser -restart –force and press Enter.
  • Type a password for the domain administrator account when prompted.

The command above adds srvcore01 and srvcore02 to ad.contoso.com domain. The account used to run the PowerShell prompt would need permission to connect and join both servers to the domain. You could also specify a list of servers in a text file (servers.txt) as follows:

add-computer -computername (get-content servers.txt) -domainname ad.contoso.com –credential AD\adminuser -restart –force

In the above command, servers.txt would need to be located in the PowerShell working directory.


Got a project that needs expert IT support?

From Linux and Microsoft Server to VMware, networking, and more, our team at CR Tech is here to help.

Get personalized support today and ensure your systems are running at peak performance or make sure that your project turns out to be a successful one!

CONTACT US NOW
one click social media designs