Join Computer to Domain
Joining a computer to domain via PowerShell is whole lot easier than regular way of GUI based.
To Join a Computer to domain,
Add-Computer -DomainName “HarmikBatth.Lab”
Enter the user credentials, which has permission to join the computer to a domain.
You can also mention the “-Restart”, which will automatically restart the computer on successfully joining to domain.
Once the computer is restarted, it is joined to domain and you can login using domain credentials.
Join Computer to Domain in Specific OU
Above command by default will put this computer into Default Computers OU. if you have requirements to move or place this computer directly into specific OU, you can follow the below procedure to do so.
Add-Computer -DomainName HarmikBatth.Lab -OUPath OU=testOU,DC=domain,DC=Domain,DC=com
The local computer is added to the organizational unit (OU) in the directory that is specified by the OUPath parameter