Hello All,

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

Sharing is caring!


  1. Jarred


    Add-Computer will fail for a specific OU if the computer account already exists.

Leave a comment

Your email address will not be published. Required fields are marked *