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.

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, _
' 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   [ - ] Hide Comments


Please log in to comment

Answer this question or Comment on this question for clarity



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

Answered 02/26/2018 by: Channeler
Ninth Degree Black Belt

Please log in to comment