/build/static/layout/Breadcrumb_cap_w.png

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!


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: andrew_lubchansky 10 years ago
2nd Degree Black Belt
0

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 10 years ago
Posted by: StockTrader 10 years ago
Red Belt
0

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 :-)

Posted by: SMal.tmcc 10 years ago
Red Belt
0

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(&quot;Enter name of domain&quot;)
    strUser = InputBox(&quot;Enter account name to use&quot;)
    strPassword = InputBox(&quot;Enter the account password&quot;)

    ' Retrieve NetBIOS name of local computer.
    Set objNetwork = CreateObject(&quot;WScript.Network&quot;)
    strComputer = objNetwork.ComputerName

    Set objComputer = GetObject(&quot;winmgmts:&quot; _
    &amp; &quot;{impersonationLevel=Impersonate,authenticationLevel=Pkt}!\\&quot; &amp; _
    strComputer &amp; &quot;\root\cimv2:Win32_ComputerSystem.Name='&quot; &amp; _
    strComputer &amp; &quot;'&quot;)

    lngReturnValue = objComputer.JoinDomainOrWorkGroup(strDomain, _
    strPassword, strDomain &amp; &quot;\&quot; &amp; strUser, strOU, _
    JOIN_DOMAIN + ACCT_CREATE)

    Wscript.Echo &quot;ReturnValue = &quot; &amp; CStr(lngReturnValue)

    Select Case lngReturnValue
    ' Some return code values (added 04/05/2010).
    Case 0
    Wscript.Echo &quot;Success joining computer to the domain!&quot;
    Case 5
    Wscript.Echo &quot;Access is denied&quot;
    Case 87
    Wscript.Echo &quot;The parameter is incorrect&quot;
    Case 110
    Wscript.Echo &quot;The system cannot open the specified object&quot;
    Case 1323
    Wscript.Echo &quot;Unable to update the password&quot;
    Case 1326
    Wscript.Echo &quot;Logon failure: unknown username or bad password&quot;
    Case 1355
    Wscript.Echo &quot;The specified domain either does not exist or could not be contacted&quot;
    Case 2224
    Wscript.Echo &quot;The account already exists&quot;
    Case 2691
    Wscript.Echo &quot;The machine is already joined to the domain&quot;
    Case 2692
    Wscript.Echo &quot;The machine is not currently joined to a domain&quot;
    Case Else
    Wscript.Echo &quot;Unknown error&quot;
    End Select - anonymous_84852 10 years ago
    • We create our machines ahead of time in AD, less hassles. - SMal.tmcc 10 years ago
 
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