Move machine to specific OU - K2000
I am looking to add a newly imaged machine to a specific OU using script provided here - https://indigomountain.co.uk/2013/06/25/kace-join-domain-and-ou/ . This will be done as part of domain join and a post install task
I am using the following script:
cscript join_domain_and_OU.vbs redgrave.local username password DNS Server OU=Windows,OU=Computers,OU=MyBusiness,DC=redgrave,DC=local
Task goes through without an error but does not add machine to domain or OU. Am I missing something?
Answer Chosen by the Author
You could use a PowerShell Post install task, to join directly to into the OU you want, just edit the first three lines with your data. Save it as PS1 file , and create a new Powershell Post Install task, attach the PS1 file.
$password= "PASSWORD" | ConvertTo-SecureString -asPlainText -Force
$cred= New-Object System.Management.Automation.PSCredential($user,$password)
$oupath = "CN=Computers,DC=DOMAIN,DC=COM"
Add-Computer -domainname $domain -oupath $oupath -Credential $cred -ErrorAction silentlycontinue
Add-Computer -DomainName $domain -Credential $cred