/build/static/layout/Breadcrumb_cap_w.png

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)

Posted by: Channeler 6 years ago
Red Belt
0
Hi

The NetSetup.log from Windows should provide clues in regards why it failed to join the domain. (or if it even tried to do it).

NetSetup.log is in C:\Windows\Debug

Join and Authentication Issues

https://technet.microsoft.com/en-us/library/cc961817.aspx

Don't be a Stranger!

Sign up today to participate, stay informed, earn points and establish a reputation for yourself!

Sign up! or login

View more:

Share

 
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