To build this tool, we'll first create a "wrapper" function around Add-Computer. Let's build a tool in PowerShell to give us some additional functionality.
Likewise, I also prefer to get some notification when the computer comes back up after a reboot. But there are some things that Add-Computer cannot do as well.įor example, I like to verify an organizational unit exists before attempting to add a computer to it. Use help Add-Computer -Detailed to see what it can do. You may also want to add the computer to a specified organizational unit, ensure that the computer rebooted successfully, and so on.įor some additional actions, the Add-Computer cmdlet provides other parameters. Using PowerShell is a great start, but chances are you need more flexibility.
#Powershell join domain specific ou how to#
In this guide, you’ll find out how to automate daily tasks related to computer accounts, such how to easily create, rename and remove accounts. $computers = Get-Content -Path C:\Computers.txtĪdd-Computer -ComputerName $computers -Domain 'domain.here' -Restart Before a user can log into a computer and access network and domain-based resources, that computer must be a member of the Active Directory environment. This method not only speeds up joining a domain on a single machine but also can easily extend to multiple devices as well if the computer names are stored somewhere else, like a text file. No more logging on computers and clicking around.
This PowerShell snippet above connects remotely to the computer NAMEHERE, attempts to join it to the domain domain.here and then afterward restarts it.