Problem with VBS script to join specific OU - K2000 post-install task
I modified the sample domain join script to include an additional variable (removing DNS variable completely) and although the script seems to run, the computers are not actually joining the domain.
Any idea what the issue could be?
Full Command Line reads: cscript join_domain_ou.vbs Username Passowrd "ou=sub,ou=top level,dc=schoolname,dc=org"
Modified vbs:
If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
' Duff arguments so return non zero so the task is marked as failed.
WScript.Quit(1)
Else
strDomain = WScript.Arguments.Item(0)
strUser = WScript.Arguments.Item(1)
strPassword = WScript.Arguments.Item(2)
strOU = WScript.Arguments.Item(3)
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, _
strOU, _
JOIN_DOMAIN+ACCT_CREATE)
' Error code 2691 means the machine was already joined to the domain, so not quite an error
If ReturnValue = 2691 Then ReturnValue = 0
WScript.Quit(ReturnValue)
0 Comments
[ + ] Show comments
Answers (1)
Please log in to answer
Posted by:
Channeler
6 years ago