To Join multiple computers to the domain you just need to create a text file and add the computer names to it. With the text file setup I’ll run the following commands: $computers = Get-Content -Path c:\it\computers.txtĪdd-Computer -ComputerName $computers -Domain "YourDomainName" -Restart I’ve saved the text file to c:\it\computers.txt In this example, I’ve created a text file called computers.txt and added PC2 and PC3 to it. The first line sets up a variable ($computers), which stores the values of the text file. The 2nd line is similar to the previous examples, now I just added the -ComputerName and the $computers variable. This command will go through every computer listed in the text file and join them to the domain. Join Computer to Domain and specify OU Path With PowerShell Pretty cool right? This will defiantly speed up the process of joining multiple computers to the domain. When you join a computer to the domain it will by default go the computers folder. It is best practice to move the computers from the default folder to a different OU. Thankfully we can automate this with PowerShell when we join the computers to the domain. Add-Computer -DomainName "Domain02" -OUPath "OU=testOU,DC=domain,DC=Domain,DC=com" Run this command to join a computer to the domain and specify the OU path. In the following example, I’ll be adding computers to the domain that go to the sales department. I have an OU setup called sales so I want the computers to automatically be moved to that OU. The PowerShell command requires the distinguished name of the OU. The easiest way to get this is by navigating to the OU in Active Directory Users and Computers and opening the properties of the OU. Then click the Attribute Editor and copy the value of distinguishedName. Now add this path to the command, below is the command for my domain. Add-Computer -DomainName "ad." -OUPath "OU=Sales,OU=ADPRO Computers,DC=ad,DC=activedirectorypro,DC=com" This will add the computer to the Sales OU in my Active Directory. I’ve just walked through three examples of using PowerShell to join computers to the domain. Now you can forget about logging into each computer and manually adding them to the domain.
0 Comments
Leave a Reply. |