Help adding PC's to a specific OU via Post Install Task (vb script)

I am adding PC's to the domain as a Post Install Task Using K2000.  The default script does allows you to put a line of custom code which seems to integrate into the VBScript pre-uploaded by Dell/Quest.  The single line of code they want  you to edit is "cscript join_domain.vbs [DOMAIN] [USERNAME] [PASSWORD] [DNS Server IP] This works without issue however I am wanting to add it to a specific OU and the default VB script just adds it to the COMPUTERS OU.  Can someone show me where to input the string for my specific OU?  The VBScript from Kace 2000 is below.

Const JOIN_DOMAIN             = 1

Const ACCT_CREATE             = 2

Const ACCT_DELETE             = 4

Const WIN9X_UPGRADE           = 16


Const JOIN_UNSECURE           = 64


Const DEFERRED_SPN_SET        = 256

Const INSTALL_INVOCATION      = 262144

If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then

' Duff arguments so return non zero so the task is marked as failed.



strDomain   = WScript.Arguments.Item(0)

strUser = WScript.Arguments.Item(1)

strPassword = WScript.Arguments.Item(2)

'set DNS IP address

If WScript.Arguments.Count = 4 Then

    strDNSIP = WScript.Arguments.Item(3)

    Set objShell = CreateObject("WScript.shell")

    objShell.Run "netsh int ip set dns ""local area connection"" static " & _

                strDNSIP &" primary", 0 , 0

  End If

End If

Set objNetwork = CreateObject("WScript.Network")

strComputer = objNetwork.ComputerName

Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _

                             strComputer & _

                             "\root\cimv2:Win32_ComputerSystem.Name='" _

                             & strComputer & "'")

ReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _

                                                strPassword, _

                                                strDomain & "\" & strUser, _

                                                NULL, _



' Error code 2691 means the machine was already joined to the domain, so not quite an error                                              

If ReturnValue = 2691 Then ReturnValue = 0


0 Comments   [ + ] Show comments

Answers (3)

Posted by: Channeler 1 month ago
Red Belt

I believe this one works too, 

It's done via Powershell, and it has a line to specify the target OU.

Posted by: usererror000 1 month ago
White Belt

how would I implement this into Kace?  will kace2k let me add a powershell script and it run this as a post install task?  

Posted by: abahelpdesk 1 month ago
Senior White Belt

We also do it with a powershell script as a post installation task. Our script looks like this:

$domain = "your.domain"

$password = "YourPassword" | ConvertTo-SecureString -asPlainText -Force

$username = "$domain\YourUser"

$credential = New-Object System.Management.Automation.PSCredential($username,$password)


add-computer -Credential $credential -DomainName $domain -OUPath $ouPath

Save this code with your domain and user information with permissions to join domain as a powershell. Afterwards you can upload the powershell as post install task like this:wGfaTzPl4jpXQAAAABJRU5ErkJggg== 
This website uses cookies. By continuing to use this site and/or clicking the "Accept" button you are providing consent Quest Software and its affiliates do NOT sell the Personal Data you provide to us either when you register on our websites or when you do business with us. For more information about our Privacy Policy and our data protection efforts, please visit GDPR-HQ