/bundles/itninjaweb/img/Breadcrumb_cap_w.png
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   [ - ] Hide Comments

Comments

Please log in to comment

Answer this question or Comment on this question for clarity

Answers

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
Answered 02/26/2018 by: Channeler
Ninth Degree Black Belt

Please log in to comment