Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to join new pc to domain 3

Status
Not open for further replies.

dbustamante

IS-IT--Management
Jul 12, 2010
63
US
I have alot of pc's i have to re-image and im trying to come out with a script or bat file to join a new pc to my domain. but im not having any luck here is what i have so far but its missing something. any ideas?

Code:
cmd /c netdom join %COMPUTERNAME% /domain:%JoinDomain% /userd:%DMID% /passwordd:%DMPW% /ou:%OU_String%,DC=%DC1%,DC=%DC2%,DC=%DC3%
 IF %ErrorLevel% EQU 0 (
 	ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel% >>%Logfile%
 	ECHO ***%~n0   Successfully joined %Computername% to %JoinWorkGroup%  >>%Logfile%
 	echo Successfully joined %Computername% to %JoinWorkGroup%
 	GOTO :CmpltJn
 	)
 IF %ErrorLevel% EQU 2224 (
 	ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel% >>%Logfile%
 	GOTO :TakeOvr
 	)
 ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel% >>%Logfile%
 REM --- Failed to join domain
 GOTO :ErrorHandler
 
 :TakeOvr
 cmd /c netdom join %COMPUTERNAME% /domain:%JoinDomain% /userd:%DMID% /passwordd:%DMPW%
 IF ErrorLevel 1 (
 	ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel%  >>%Logfile%
 	REM --- Failed to join domain
 	GOTO :ErrorHandler
 	)
 IF %ErrorLevel% EQU 0 ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel%  >>%Logfile%
 
 REM --- Moves object to specified OU.  Ensures object is in correct location.  Shorter than testing and then moving is simply moving.
 cmd /c dsquery computer domainroot -d %JoinDomain% -name %ComputerName%|dsmove -newparent "%OU_String%,DC=%DC1%,DC=%DC2%,DC=%DC3%" -U %DMID% -P %DMPW%
 IF ErrorLevel 1 (
 	ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel%  >>%Logfile%
 	REM --- Failed to move to correct OU
 	GOTO :ErrorHandler
 	)
 IF %ErrorLevel% EQU 0 ECHO ***%~n0     Returned ErrorLevel - %ErrorLevel%  >>%Logfile%
 
 :CmpltJn
 
'author: mrmovie
'description: script to add machine to domain
'version=1.2
' updated mrmovie, returncode 2224 odd behavour where the inital discovery said it couldnt find machine account in AD
'but the WMI method says there is already one there...
' 1.2, 4.1.2.0, 7/12/2008, updated mrmovie, added the defou switch to override the strOU so we can just let it build into the domains default ou



Option Explicit
Dim intReturn
Call Main("", "", "", "", "", "")
If intReturn <> 0 Then
WScript.Quit intReturn
Else
WScript.Quit Err.Number
End If



'sub to add machine to domain, will error i believe if there is a machine account there already
'that type of check should be done before with a different thread.
Sub Main(ByVal strDomain, ByVal strPassword, ByVal strUsername, ByVal strOU, ByVal strDeleteAccount, ByVal strDefOU)

Dim WshNetwork, objComputer, strComputer, blnDeleteAccount, blnCreateAccount, blnTargetOK

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2

'overwrite these with arguments passed at cmdline
If Wscript.Arguments.Named.Exists("help") Then
Wscript.Echo "joindomain.vbs CmdLine Params:" & vbCrLf & "/domain:<domain2join>" & vbCrLf & _
"/username:<username>" & vbCrLf & "/password:<password>" & VbCrLf & _
"parameters are case sensitive." & vbCrLf & vbCrLf & _
"example: joindomain.vbs /username:addtodomain /domain:domainX.local /password:password123"
Wscript.Quit
End If
'get the domain?
If Wscript.Arguments.Named.Exists("domain") Then
strDomain = Wscript.Arguments.Named.Item("domain")
End If
'get the password
If Wscript.Arguments.Named.Exists("password") Then
strPassword = Wscript.Arguments.Named.Item("password")
End If
'get the username
If Wscript.Arguments.Named.Exists("username") Then
strUsername = Wscript.Arguments.Named.Item("username")
End If
'get the ou
If Wscript.Arguments.Named.Exists("ou") Then
strOU = Wscript.Arguments.Named.Item("ou")
End If
'build into default ou
If Wscript.Arguments.Named.Exists("defou") Then
strDefOU = LCase(Wscript.Arguments.Named.Item("defou"))
End If
'get the ou
If Wscript.Arguments.Named.Exists("deleteaccount") Then
strDeleteAccount = Wscript.Arguments.Named.Item("deleteaccount")
End If
'shall we delete the old machine account?
If LCase(strDeleteAccount) = "true" Then
blnDeleteAccount = True
Else
blnDeleteAccount = False
End If
'default create account, will update later by checking for existance of machine account
blnCreateAccount = True
'can we use the target OU?
blnTargetOK = True
'Wscript.Quit
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
Set WshNetwork = Nothing
'Wscript.Echo strPassword
'Wscript.Echo strUsername
'Wscript.Echo strDomain
Wscript.Echo strOU
'does out target OU exist
Dim objTargetOU, adsNameSpace, strTemp
Set adsNameSpace = GetObject("LDAP:")
On Error Resume Next
Set objTargetOU = adsNamespace.OpenDSObject("LDAP://" & strDomain & ":389/" & strOU, strUsername, strPassword, 1)
strTemp = objTargetOU.name
On Error GoTo 0
If strTemp = "" Then
intReturn = 333
Exit Sub
End If

'does the machine account already exist in the domain?
Dim adoConnection, adoCommand, adoRecordSet, strQuery
Dim strDN, strMachineOU, strName
strMachineOU = "_blank_"
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Properties("User ID") = strUserName
adoConnection.Properties("Password") = strPassword
adoConnection.Properties("Encrypt Password") = True
'MsgBox "W1"
adoConnection.Open("Active Directory Provider")
'MsgBox "W2"
Set adoCommand = CreateObject("ADODB.Command")
adoCommand.ActiveConnection = adoConnection
adoCommand.Properties("Page Size") = 1000
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = True
strQuery = "<LDAP://" & strDomain & ":389>;(&(objectCategory=computer)(objectClass=computer)(name=" & Trim(strComputer) & "));" _
& "cn,DistinguishedName,name,SerialNumber;subtree"
adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute
'more than one machine object has this serial number associated with it!!!! oh dear, bad, bad, bad
If adoRecordset.recordCount > 1 Then
Wscript.Echo "There are " & adoRecordSet.recordCount & " machines with the same Name (" & Trim(strComputer) & ")"
End If

'we have found a pre-existing machine account with this machines serial number associated with it
'lets get the distinguisedname and see if it matches our machine name
If adoRecordset.recordCount = 1 Then
Wscript.Echo "found one machine with that info"
Do Until adoRecordset.EOF
strDN = adoRecordset.Fields("DistinguishedName").Value
strMachineOU = Right(strDN, Len(strDN) - InStr(strDN, ","))
'MsgBox strMachineOU
strName = adoRecordset.Fields("name").Value
'txthostname.innertext = UCase(strName)
adoRecordset.MoveNext()
Loop
'ok we have a machine account with the serial number in question, does it match the machinename we are trying to build?
If strDN <> "" And strMachineOU <> "" And strName <> "" Then
Wscript.Echo strDN & " " & strMachineOU & " " & strName
End If
End If

'do we have a pre-existing machine account and is it in the right place?
If strMachineOU <> "_blank_" Then
WScript.Echo "machine name already exists"
'should we delete the old machine account
If blnDeleteAccount = True Then
'ok we need to delete the account
Else
'we dont need to delete the account, we need to move it if it is not in the right place already
'is it in the right place?
If strMachineOU = strOU Then
WScript.Echo "machine in the right ou already"

Else
WScript.Echo "not in the right ou"
'we definitely need to move it
If strDN <> "" Then
'not sure i really need to bind to this object! i have the ADsPath and Name already!!!!
Set objComputer = adsNamespace.OpenDSObject("LDAP://" & strDomain & ":389/" & strDN, strUsername, strPassword, 1)
'Set objComputer = GetObject("LDAP://" & strDN)
Dim intA
On Error Resume Next
WScript.Echo objComputer.ADsPath & " .... " & objComputer.Name
WScript.Echo objTargetOU.ADsPath
objTargetOU.MoveHere objComputer.ADsPath, objComputer.Name
'MsgBox intA
'If intA <> 0 Or intA = "" Then
If Err.Number <> 0 Then
blnTargetOK = False
End If
On Error Goto 0
Set objComputer = Nothing
End If
End If
End If
'we dont need to create machine account as it is already there
blnCreateAccount = False
Else
WScript.Echo "machine name is not there, nice one"
End If
'WScript.Quit

Set objTargetOU = Nothing

'MsgBox ""

'are we ok to move into the target OU?
If blnTargetOK = False Then
intReturn = "666"
strOU = strMachineOU
End If

'######################################
If InStr(strUserName, "\") Then
WScript.Echo strUsername ' just do something
Else
strUserName = strDomain & "\" & strUsername
End If

Dim intAction
If blnCreateAccount = False Then
intAction = JOIN_DOMAIN
Else
intAction = JOIN_DOMAIN + ACCT_CREATE
End If

'Set objComputer = Nothing
'strOU = ""
Set objComputer = GetObject("winmgmts:!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
If strDefOU = "true" Then
WScript.Echo strDomain & " " & strPassword & " " & strUsername & " " & Null & " " & intAction
'MsgBox ""
intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUsername, Null, intAction)
Else
WScript.Echo strDomain & " " & strPassword & " " & strUsername & " " & strOU & " " & intAction
'MsgBox ""
intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUserName, strOU, intAction)
End If
Wscript.Echo "returncode=" & intReturn

If intReturn = "2224" Then
'ok something silly is going on, JoinDomain method is reporting that the machine account already exists!
intAction = JOIN_DOMAIN
If strDefOU = "true" Then
WScript.Echo strDomain & " " & strPassword & " " & strUsername & " " & Null & " " & intAction
'MsgBox ""
intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUsername, Null, intAction)
Else
WScript.Echo strDomain & " " & strPassword & " " & strUsername & " " & strOU & " " & intAction
'MsgBox ""
intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUserName, strOU, intAction)
End If
End If
Wscript.Echo "returncode=" & intReturn
Set objComputer = Nothing

'SERIAL NUMBER UPDATE........
'update the machine account details with the serial number information....


'Wscript.Quit intReturn
'Const ACCT_DELETE = 4
'Const WIN9X_UPGRADE = 16
'Const DOMAIN_JOIN_IF_JOINED = 32
'Const JOIN_UNSECURE = 64
'Const MACHINE_PASSWORD_PASSED = 128
'Const DEFERRED_SPN_SET = 256
'Const INSTALL_INVOCATION = 262144



End Sub

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
ok so i took what you gave me and i entered all my information but its still not working did i skip something or did i enter something in the wrong spot? here is what i have.

Code:
'author: mrmovie
'description: script to add machine to domain
'version=1.2
'    updated mrmovie, returncode 2224 odd behavour where the inital discovery said it couldnt find machine account in AD
        'but the WMI method says there is already one there...
'    1.2, 4.1.2.0, 7/12/2008, updated mrmovie, added the defou switch to override the strOU so we can just let it build into the domains default ou



Option Explicit
Dim intReturn
Call Main("", "", "", "", "", "")
If intReturn <> 0 Then
    WScript.Quit intReturn
Else
    WScript.Quit Err.Number
End If



'sub to add machine to domain, will error i believe if there is a machine account there already
'that type of check should be done before with a different thread.
Sub Main(ByVal strDomain, ByVal strPassword, ByVal strUsername, ByVal strOU, ByVal strDeleteAccount, ByVal strDefOU)

Dim WshNetwork, objComputer, strComputer, blnDeleteAccount, blnCreateAccount, blnTargetOK

Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2

'overwrite these with arguments passed at cmdline
If Wscript.Arguments.Named.Exists("help") Then
    Wscript.Echo "joindomain.vbs CmdLine Params:" & vbCrLf & "/domain:<domain2join>" & vbCrLf & _
        "/username:<[COLOR=red]administrator[/color]>" & vbCrLf & "/password:<[COLOR=red]Rgdcdomain[/color]>" & VbCrLf & _
        "parameters are case sensitive." & vbCrLf & vbCrLf & _
        "example: joindomain.vbs /username:[COLOR=red]administrator[/color] /domain:[COLOR=red]RGDCDOMAIN.LOCAL[/color] /password:[COLOR=red]Rgdcmis76[/color]"
    Wscript.Quit
End If
'get the domain?
If Wscript.Arguments.Named.Exists("[COLOR=red]rgdc[/color]") Then
    strDomain = Wscript.Arguments.Named.Item("[COLOR=red]rgdc[/color]")
End If
'get the password
If Wscript.Arguments.Named.Exists("[COLOR=red]Rgdcmis1001[/color]") Then
    strPassword = Wscript.Arguments.Named.Item("[COLOR=red]Rgdcmis1001[/color]")
End If
'get the username
If Wscript.Arguments.Named.Exists("[COLOR=red]administrator[/color]") Then
    strUsername = Wscript.Arguments.Named.Item("administrator")
End If
'get the ou
If Wscript.Arguments.Named.Exists("ou") Then
    strOU = Wscript.Arguments.Named.Item("ou")
End If
'build into default ou
If Wscript.Arguments.Named.Exists("defou") Then
    strDefOU = LCase(Wscript.Arguments.Named.Item("defou"))
End If
'get the ou
If Wscript.Arguments.Named.Exists("deleteaccount") Then
    strDeleteAccount = Wscript.Arguments.Named.Item("deleteaccount")
End If
'shall we delete the old machine account?
If LCase(strDeleteAccount) = "true" Then
    blnDeleteAccount = True
Else
    blnDeleteAccount = False
End If
'default create account, will update later by checking for existance of machine account
blnCreateAccount = True
'can we use the target OU?
blnTargetOK = True
'Wscript.Quit
Set WshNetwork = CreateObject("WScript.Network")
strComputer = WshNetwork.ComputerName
Set WshNetwork = Nothing
'Wscript.Echo strPassword
'Wscript.Echo strUsername
'Wscript.Echo strDomain
Wscript.Echo strOU
'does out target OU exist
Dim objTargetOU, adsNameSpace, strTemp
Set adsNameSpace = GetObject("LDAP:")
On Error Resume Next
Set objTargetOU = adsNamespace.OpenDSObject("LDAP://" & strDomain & ":389/" & strOU, strUsername, strPassword, 1)
strTemp = objTargetOU.name
On Error GoTo 0
If strTemp = "" Then
    intReturn = 333
    Exit Sub
End If

'does the machine account already exist in the domain?
Dim adoConnection, adoCommand, adoRecordSet, strQuery
Dim strDN, strMachineOU, strName
strMachineOU = "_blank_"
Set adoConnection = CreateObject("ADODB.Connection")
adoConnection.Provider = "ADsDSOObject"
adoConnection.Properties("User ID") = strUserName
adoConnection.Properties("Password") = strPassword
adoConnection.Properties("Encrypt Password") = True
'MsgBox "W1"
adoConnection.Open("Active Directory Provider")
'MsgBox "W2"
Set adoCommand = CreateObject("ADODB.Command")
adoCommand.ActiveConnection = adoConnection
adoCommand.Properties("Page Size") = 1000
adoCommand.Properties("Timeout") = 30
adoCommand.Properties("Cache Results") = True
strQuery = "<LDAP://" & strDomain & ":389>;(&(objectCategory=computer)(objectClass=computer)(name=" & Trim(strComputer) & "));" _
           & "cn,DistinguishedName,name,SerialNumber;subtree"
adoCommand.CommandText = strQuery
Set adoRecordset = adoCommand.Execute
'more than one machine object has this serial number associated with it!!!! oh dear, bad, bad, bad
If adoRecordset.recordCount > 1 Then
     Wscript.Echo "There are " & adoRecordSet.recordCount & " machines with the same Name (" & Trim(strComputer) & ")"
End If

'we have found a pre-existing machine account with this machines serial number associated with it
'lets get the distinguisedname and see if it matches our machine name
If adoRecordset.recordCount = 1 Then
    Wscript.Echo "found one machine with that info"
    Do Until adoRecordset.EOF
        strDN = adoRecordset.Fields("DistinguishedName").Value
        strMachineOU = Right(strDN, Len(strDN) - InStr(strDN, ","))
        'MsgBox strMachineOU
        strName = adoRecordset.Fields("name").Value
        'txthostname.innertext = UCase(strName)
        adoRecordset.MoveNext()
    Loop
    'ok we have a machine account with the serial number in question, does it match the machinename we are trying to build?
    If strDN <> "" And strMachineOU <> "" And strName <> "" Then
         Wscript.Echo strDN & " " & strMachineOU & " " & strName  
    End If
End If

'do we have a pre-existing machine account and is it in the right place?
If strMachineOU <> "_blank_" Then
    WScript.Echo "machine name already exists"
    'should we delete the old machine account
    If blnDeleteAccount = True Then
        'ok we need to delete the account
    Else
        'we dont need to delete the account, we need to move it if it is not in the right place already
        'is it in the right place?
        If strMachineOU = strOU Then
            WScript.Echo "machine in the right ou already"
            
        Else
            WScript.Echo "not in the right ou"
            'we definitely need to move it
            If strDN <> "" Then
                'not sure i really need to bind to this object!  i have the ADsPath and Name already!!!!
                Set objComputer = adsNamespace.OpenDSObject("LDAP://" & strDomain & ":389/" & strDN, strUsername, strPassword, 1)
                'Set objComputer = GetObject("LDAP://" & strDN)
                Dim intA
                On Error Resume Next
                WScript.Echo objComputer.ADsPath & " .... " & objComputer.Name
                WScript.Echo objTargetOU.ADsPath
                objTargetOU.MoveHere objComputer.ADsPath, objComputer.Name
                'MsgBox intA
                'If intA <> 0 Or intA = "" Then
                If Err.Number <> 0 Then
                    blnTargetOK = False
                End If
                On Error Goto 0
                Set objComputer = Nothing
            End If
        End If
    End If
    'we dont need to create machine account as it is already there
    blnCreateAccount = False
Else
    WScript.Echo "machine name is not there, nice one"
End If
'WScript.Quit

Set objTargetOU = Nothing

'MsgBox ""

'are we ok to move into the target OU?
If blnTargetOK = False Then
    intReturn = "666"
    strOU = strMachineOU
End If

'######################################
If InStr(strUserName, "\") Then 
    WScript.Echo strUsername    ' just do something
Else 
    strUserName = strDomain & "\" & strUsername
End If

Dim intAction
If blnCreateAccount = False Then
    intAction = JOIN_DOMAIN
Else
    intAction = JOIN_DOMAIN + ACCT_CREATE
End If

'Set objComputer = Nothing
'strOU = ""
Set objComputer = GetObject("winmgmts:!\\" & strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & strComputer & "'")
If strDefOU = "true" Then
    WScript.Echo strDomain & " " & strPassword & " " &  strUsername & " " &  Null & " " &  intAction
    'MsgBox ""
    intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUsername, Null, intAction)
Else
    WScript.Echo strDomain & " " & strPassword & " " &  strUsername & " " & strOU & " " & intAction
    'MsgBox ""
    intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUserName, strOU, intAction)
End If
Wscript.Echo "returncode=" & intReturn

If intReturn = "2224" Then
    'ok something silly is going on, JoinDomain method is reporting that the machine account already exists!
    intAction = JOIN_DOMAIN
    If strDefOU = "true" Then
        WScript.Echo strDomain & " " & strPassword & " " &  strUsername & " " &  Null & " " &  intAction
        'MsgBox ""
        intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUsername, Null, intAction)
    Else
        WScript.Echo strDomain & " " & strPassword & " " &  strUsername & " " & strOU & " " & intAction
        'MsgBox ""
        intReturn = intReturn + objComputer.JoinDomainOrWorkGroup(strDomain, strPassword, strUserName, strOU, intAction)
    End If
End If
Wscript.Echo "returncode=" & intReturn
Set objComputer = Nothing

'SERIAL NUMBER UPDATE........
'update the machine account details with the serial number information....


'Wscript.Quit intReturn
'Const ACCT_DELETE = 4
'Const WIN9X_UPGRADE = 16
'Const DOMAIN_JOIN_IF_JOINED = 32
'Const JOIN_UNSECURE = 64
'Const MACHINE_PASSWORD_PASSED = 128
'Const DEFERRED_SPN_SET = 256
'Const INSTALL_INVOCATION = 262144



End Sub
 
dont change what i have posted
instead call it from a command prompt like

cscript.exe joindomain.vbs /domain:mydomain.com /username:mydomain\elevatedaccount_name /password:your_pwd /ou:"OU=DEV,OU=Machines,DC=mydomain,DC=com" /deleteaccount:false



I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
OH OK so i go to the command promt and type cscirpt.exe and i entered what you told me to with and without my credentials but it says 'joindomain.vbs' is not recognized as an internal or external command, operable program or batch file.

ive also tried doing the whole path C:\documents and settings\administrator\desktop\joindomain.vbs /domain:mydomain.com /username:rgdc\administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=Machines,DC=RGDC,DC=com"/deleteaccount:false

so i entered it with out the full file path and
joindomain.vbs /domain:mydomain.com /username:rgdc\administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=A2,DC=RGDC,DC=com"

but i get the same results
 
did you copy and paste my original post and create a joindomain.vbs file?
if you are running from a command prompt and the location of the vbs has white space in the path, like yours does then it would need to be
cscript.exe "the path to the file\joindomain.vbs"...etc

i can only say that that script has been in prod for about 7 years, you should find it works fine, once you get round the use of hte params and the cscript.exe stuff

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
yup i copied the original post and made the joindomain.vbs.
yea im getting further today then i did yesterday now im actually getting a pop up box saying

"windows Script Host"
OU=DEV,OU=Machine,DC=RGDCDOMAIN,DC=com

and yesterday it was just closeing out on me so there is progress its just the last step of the puzzle that i need.
 
you are running the script using wscript.exe, that is why you are getting the popup. start the script using cscript.exe, e.g.

from a command prompt

cscript.exe joindomain.vbs ''''the parameters''''

or change your default scripting host to be cscript.exe

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
ok there we go I made script.exe my default and the popups are gone everything staying in the command prompt but nothings happing i think the part thats stopping it is

Code:
Desktop\joindomain.vbs /domain:mydomain.com /username:dbustamante /password:Rgdcmis76 /ou:"OU=DEV,OU=[COLOR=red]A2[/color],DC=[COLOR=red]RGDCDOMAIN[/color],DC=com" /deleteaccount:false

i think once i get the last part down it should run smooth ive tried leaving it as WORKGROUP where it says my domain but it had the same affect. when you enter it what are you supposed to enter for the last part "ou:"OU=DEV,OU=Machines,DC=mydomain,DC=com" /deleteaccount:false
 
the /ou: parameter is asking you which OU you would like to put the computer account into, when you join the domain.

the /deleteaccount is asking if you wish to delete a pre-existing machine account, i would leave this as false to start off with

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
ok i made the modifications to the parameters and this is what I’ve come up with.

Code:
desktop\joindomain.vbs /domain:mydomain.com /username:rgdcdomain\administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=[COLOR=red]RGDCDOMAIN.LOCAL/RGDCcomputers[/color] ,DC=[COLOR=red]RGDCDOMAIN[/color] ,DC=com"/deleteaccount:false

but every time i enter it this is what comes out
Code:
[COLOR=red]Microsoft (R) Windows Script Host Version 5.7
Copyright (C) Microsoft Corporation. All rights reserved.

OU=DEV,OU=RGDCDOMAIN.LOCAL/RGDCcomputers,DC=RGDCDOMAIN,DC=com/deleteaccount:false

C:\Documents and Settings\Administrator\Desktop>[/color]
like it wants me to enter some thing else
 
if your domain really called 'mydomain.com'? i doubt this considering you are using a /username of rgdcdomain\administrator

after you run the cscript.exe you can type, at the command prompt, 'echo %errorlevel%'
this should give you the return code from the execution of the vbscript...what is it?

I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
my domain name RGDCDOMAIN so i changed it up entered my domain name where the mydomain.com so it looks like this now
Code:
desktop\joindomain.vbs /domain:RGDCDOMAIN /username:RGDCDOMAIN/administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=RGDCDOMAIN.LOCAL/RGDCcomputers,DC=RGDCDOMAIN,DC=com"/deleteaccount:false

and the error code is 333
 
What about this ?
desktop\joindomain.vbs /domain:RGDCDOMAIN /username:RGDCDOMAIN/administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=RGDCDOMAIN.LOCAL/RGDCcomputers,DC=RGDCDOMAIN,DC=com"[highlight] [/highlight]/deleteaccount:false

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
i tried it with the space and did the same thing except it left out.

/deleteaccount:false
 
Your ou rdn has that much twisted that chances are it is wrong. Make sure it is displayed exactly that in any gui like aduc.

If that is what displayed, then at least it is wrong to input the name like that. You have to escape the forward slash.
[tt]
/domain:RGDCDOMAIN /username:RGDCDOMAIN/administrator /password:Rgdcmis1001 /ou:"OU=DEV,OU=RGDCDOMAIN.LOCAL[red]\[/red]/RGDCcomputers,DC=RGDCDOMAIN,DC=com" /deleteaccount:false
[/tt]
Also, you do not just
>tried it with the space
You have to. Don't just try!

Q: If there are 10 spots that may result in error in the line and each spot has two possible action possible, do you know how much a difference is with one error corrected?
A: (2^10 - 2^9) less to debug.
 
tsujI your right so In adding the space I changed the username to my user name and password I added OU to just be RGDCcomputers because that’s the way It In my GUI now Im not sure If the DC= are correct

Code:
desktop\joIndomaIn.vbs /domaIn:RGDCDOMAIN /username:dbustamante /password:RgdcmIs76 /ou:"OU=DEV,OU=RGDCcomputers,DC=RGDCDOMAIN,DC=LOCAL" /deleteaccount:false

when I fIrst go to enter the domaIn I enter RGDCDOMAIN then It asks me for my credentIals after I enter them and I get the welcome to the RGDCDOMAIN I look at It and It shows "RGDCDOMAIN.LOCAL" which Is why I put that In the DC= I could be wrong though.
 
sorry Gents, i thought by posting a 'working' example it would save a lot of time :)

dbustamantle, the return code of 333 is coming from this part:

Set adsNameSpace = GetObject("LDAP:")
On Error Resume Next
Set objTargetOU = adsNamespace.OpenDSObject("LDAP://" & strDomain & ":389/" & strOU, strUsername, strPassword, 1)
strTemp = objTargetOU.name
On Error GoTo 0
If strTemp = "" Then
intReturn = 333
Exit Sub
End If


it means that one or more of the supplied paramters strDomain, strOU and username and password are not correct

the username parameter needs to be fully qualified, e.g. it needs to contain the domain as well, e.g. RGDCDOMAIN\dbustamante

to double check your 'real' domain name log into the domain on a machine and go to the command prompt and type 'SET' this should give you your USERDOMAIN, use this value in the strUsername parameter for the domain, infact, use it for your /domain: parameter, teh /ou, as suggested get this from adsiedit.msc


I Hear, I Forget
I See, I Remember
I Do, I Understand

Ronald McDonald
 
ok i added the RGDCDOMAIN\ to the username and the domain plus DC= like you told me to the true domain name is RGDCDOMAIN the only time it has local is when its the userdnsdomain so i left it out also i downloaded adsiedit.msc and the OU=RGDCcomputers is correct. the user name and password are correct those are my credentials that i log on to and am currently useing to join pc's to the domain but what im curious to know on the bottom of the script
Code:
 ou:"OU=DEV,OU=RGDCcomputers,DC=RGDCDOMAIN,DC=" /deleteaccount:false
what do i put in the second DC= ?
here is what i have so far
Code:
desktop\joindomain.vbs /domaIn:RGDCDOMAIN /username:RGDCDOMAIN\dbustamante /password:Rgdcmis76 /ou:"OU=DEV,OU=RGDCcomputers,DC=RGDCDOMAIN,DC=[COLOR=red]?[/color]" /deleteaccount:false
 
>what do i put in the second DC= ?
It is most probably DC=LOCAL would be your case from the look of the previous posts.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top