This is a basic PowerShell script to add a computer in a specific OU in our Active Directory. There are 3 pre-requisites:
- PowerShell needs to be installed in the server.
- PowerShell needs to be executed as Administrator.
- The AD account you use should have enougt privielges to add compoters within the OU.
Set-Executionpolicy unrestricted –> To allow PowerShell Scripts
$secPass=ConvertTo-SecureString $PWD -AsPlainText -Force
$cred= New-object System.Management.Automation.PSCredential -ArgumentList “$ACCOUNT@$DOMAIN”, $secPass
Add-Computer -DomainName $DOMAIN -OUPath $VM-OU -credential $cred