Scripting Question

Problem with VBS script to join specific OU - K2000 post-install task

02/21/2018 1347 views
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   [ + ] Show comments


All Answers


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
Red Belt

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