Re-name Computer and Bind to Domain
Hi,
For the past few months we've been using getcomputername.exe as a Pre-Install Task, and setcomputername.exe as a Mid-Level Install Task, to name our machines. We've been happy with it as our naming convention is varied, e.g. it doesn't work off machine hardware like a serial number, and we like having a prompt.
We're now working on binding the machine to Active Directory but have had little success. So far we've tried using the join_domain.vbs that's already loaded onto the K2000. I've edited the Command Line options to input our domain, username, password and DNS server. For some reason the scripted installs run as normal but there's no binding occuring. I've checked obvious things like is the machine in AD etc. Am i meant to be editing this join_domain.vbs file at all? Any ideas?
Thanks for your help!
Answers (3)
When you are editing the Join Domain Postinstall task, are you removing the <> from the command line?
Comments:
-
I thought you might have been onto something there as i did leave the <> in. Unfortunately it's still not binding. I have it running as the last post-installation task on our Windows XP scripted installs. Will try Windows 7 and see if there is any difference due to auto-login on our admin account... - anonymous_84852 11 years ago
Hello,
do you have other post installation task? Are they working fine?
Remember that if you are deploying an image of an OS and if the OS is not ''sysprepped'' the post installation actions are not going to be executed.
Have you tried, as a test, to execute the script manually on a machine that is not joined to the domain yet to see if it works or not??
You can invoke it in this way from command line:
cscript join_domain.vbs "thedomain" "Administrator" "thepassword"
Do not specify the user in the form domain\user but only specify the user name of a domain user that is able to add machines to the domain.
Another good idea might be the one to redirect the output of the script in the post install action to a file to see if there is some output there;
You can try to modify the postinstallation action in this way: (example)
join_domain.vbs "mydomain" "admin" "mypass" > c:\logscript.txt
Kind regards,
Marco - StockTrader :-)
For images when I sysprep I do not put the machine name in the answer file. When I image I use the get and apply computer name scripts if I want to keep the name, If I do not use the 2 scripts it prompts for a name. during post the machines join to the domain whether I named them or the scripts named them. I copied the join domain script into my images so I call it from the local drive.
start /wait cscript.exe c:\windows\w2d\join_domain.vbs tmccacad.tmcc.edu DomainUserWithJionRights Password.
this is the vb script (it is unaltered)
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
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
If WScript.Arguments.Count < 3 or WScript.Arguments.Count > 4 Then
WScript.Quit
Else
strDomain = WScript.Arguments.Item(0)
strUser = WScript.Arguments.Item(1)
strPassword = WScript.Arguments.Item(2)
'set DNS IP address
If WScript.Arguments.Count = 4 Then
strDNSIP = WScript.Arguments.Item(3)
Set objShell = CreateObject("WScript.shell")
objShell.Run "netsh int ip set dns ""local area connection"" static "& _
strDNSIP &" primary",0,0
End If
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, _
NULL, _
JOIN_DOMAIN+ACCT_CREATE)
Comments:
-
Thank you all for your help. I've managed to get it working by editing the VBS script to include a prompt for username, password and domain, and remove the automatic adding of the account to AD as our structure is too complicated, therefore we add the machine in manually. I've set it to run as the last post-install task without any switches. In case anyone is interested, here is our script:
Const JOIN_DOMAIN = 1
Const ACCT_CREATE = 2
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
' Prompt for credentials.
strDomain = InputBox("Enter name of domain")
strUser = InputBox("Enter account name to use")
strPassword = InputBox("Enter the account password")
' Retrieve NetBIOS name of local computer.
Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objComputer = GetObject("winmgmts:" _
& "{impersonationLevel=Impersonate,authenticationLevel=Pkt}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")
lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
strPassword, strDomain & "\" & strUser, strOU, _
JOIN_DOMAIN + ACCT_CREATE)
Wscript.Echo "ReturnValue = " & CStr(lngReturnValue)
Select Case lngReturnValue
' Some return code values (added 04/05/2010).
Case 0
Wscript.Echo "Success joining computer to the domain!"
Case 5
Wscript.Echo "Access is denied"
Case 87
Wscript.Echo "The parameter is incorrect"
Case 110
Wscript.Echo "The system cannot open the specified object"
Case 1323
Wscript.Echo "Unable to update the password"
Case 1326
Wscript.Echo "Logon failure: unknown username or bad password"
Case 1355
Wscript.Echo "The specified domain either does not exist or could not be contacted"
Case 2224
Wscript.Echo "The account already exists"
Case 2691
Wscript.Echo "The machine is already joined to the domain"
Case 2692
Wscript.Echo "The machine is not currently joined to a domain"
Case Else
Wscript.Echo "Unknown error"
End Select - anonymous_84852 11 years ago-
We create our machines ahead of time in AD, less hassles. - SMal.tmcc 11 years ago