Move machine to specific OU - K2000
Hi,
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?
Answers (2)
Top Answer
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.
$domain= "DOMAIN.COM"
$password= "PASSWORD" | ConvertTo-SecureString -asPlainText -Force
$user= "$domain\USER"
$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
Comments:
-
Thanks Channeler, this worked like a charm - kace_admin 5 years ago
You should try it without the DNS Server. If I remember rightly it used to cause some issues with the vb script.
Comments:
-
What format should the username be? domain\username or just username - SMal.tmcc 5 years ago
-
It worked with just Username, I believe. Long time since I used it though. PowerShell all the way. - Ziggi 5 years ago
-
Thanks Ziggi for your reply. But I dropped the vbscript in favor of the Powershell script and so have not tested the dropping of DNS server - kace_admin 5 years ago
When the task fails it should be right there. - Channeler 5 years ago