06/19/2019 148 views


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 Summary:
1 Comment   [ + ] Show comment


  • And What is the return code from Windows??

    When the task fails it should be right there.

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.

$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
Answered 06/19/2019 by: Channeler
Red Belt

  • Thanks Channeler, this worked like a charm

All Answers


You should try it without the DNS Server. If I remember rightly it used to cause some issues with the vb script.

Answered 06/20/2019 by: Ziggi
Purple Belt

  • What format should the username be? domain\username or just username
    • It worked with just Username, I believe. Long time since I used it though. PowerShell all the way.
  • 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