With PowerShell you can quickly add single or multiple computers at a time. Now you can forget about logging into each computer and manually adding them to the domain. I’ve just walked through three examples of using PowerShell to join computers to the domain. This will add the computer to the Sales OU in my Active Directory.Īdd-Computer -DomainName “ ad.” -OUPath “OU=Sales,OU=ADPRO Computers,DC=ad,DC=activedirectorypro,DC=com” Now add this path to the command, below is the command for my domain. Then click the Attribute Editor and copy the value of distinguishedName. 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. The PowerShell command requires the distinguished name of the OU. I have an OU setup called sales so I want the computers to automatically be moved to that OU. In the following example, I’ll be adding computers to the domain that go to the sales department. Run this command to join a computer to the domain and specify the OU path.Īdd-Computer -DomainName “Domain02” -OUPath “OU=testOU,DC=domain,DC=Domain,DC=com” Thankfully we can automate this with PowerShell when we join the computers to the domain. It is best practice to move the computers from the default folder to a different OU. When you join a computer to the domain it will by default go the computers folder. 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. This command will go through every computer listed in the text file and join them to the domain. The 2nd line is similar to the previous examples, now I just added the -ComputerName and the $computers variable. The first line sets up a variable ($computers), which stores the values of the text file. $computers = Get-Content -Path c:\it\computers.txt Add-Computer -ComputerName $computers -Domain “YourDomainName” -Restart With the text file setup I’ll run the following commands: 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. To Join multiple computers to the domain you just need to create a text file and add the computer names to it. Tip: Run help add-computer to see all the command line options (syntax) Join Multiple Computers to the Domain From a Text File The computer should automatically restart and be joined to the domain. This will need to be a Domain Administrator account or a user that has been delegated rights to join computers to the domain. You will get prompted to enter your credentials. Change YourDomainName to your Active Directory domain name.Īdd-computer –domainname “YourDomainName” -restartĮxample picture below running on my domain ad. Open Powershell and run the following command. To do this just right-click the PowerShell icon and select “Run as Administrator”. Important Tip: You may need to run PowerShell as Administrator to avoid access denied errors. Join Single Computer To Domain with Powershell FullyQualifiedErrorId : AddressResolutionException," CategoryInfo : InvalidArgument: ( OLDPCNAME :String), InvalidOperationException Add-Computer -ComputerName OLDPCNAME –DomainName my. $creddomain = Get-Credential DOMAIN\domain_adminĪdd-Computer -ComputerName OLDPCNAME –DomainName MY.DOMAIN.COM -NewName NEWPCNAME -LocalCredential $credlocal -DomainCredential $creddomain -Force -PassThru -Restartīut When I execute the command I am prompted for both credential passwords (as intended) but then the command errors out as: "Add-Computer : Computer name OLDPCNAME cannot be resolved with the exception: One or more errors occurred. So, I am planning to be done this process automatically for all of the computers.Ībsolutely my answers is PowerShell and I am manage to create a script line by like Here are the PS commands I am using: $credlocal = Get-Credential COMPUTERNAME\local_admin I know so many smart IT Pro gone through this road and manage to create an automated way to this process. So, I cannot sit in front of every computer remove that from the domain, rename it and again join a new domain. We have about 100 computers which need to be removed from the domain, renamed and joined to a new domain.
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |