powershell – add PC to domains

$domain = "example.local"
$password = "secret" | ConvertTo-SecureString -asPlainText -Force
$username = "$domain\ad-add"
$credential = New-Object System.Management.Automation.PSCredential($username,$password)
Add-Computer -DomainName $domain -OUPath "OU=New_Computers,OU=Computers,DC=example,DC=local" -Credential $credential -Restart

Leave a Reply

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