RoamingBison
MIS
I have been fighting with this script for days now, and can't find a way to make it work.
Before we created all the machine names in AD I could make this work (with options 1 & 2). However it will always fail if the computer account is already created in AD. I have tried literally dozens of different permutations of domain join scripts, and nothing seems to work correctly.
How I am using this script: This is part of a setup routine for touchscreen computers on the shop floor. The computers are all currently in "Workgroup", however we want to move them over to the domain. This setup routine will also be used to make swapping out a terminal simpler in case a machine fails.
The machine setup process: From a generic ghost image, I set up the individual station and rename it using a HTA. This script is copied over to the root of the drive, and called via runonce key that will execute after the reboot from the name change.
Code:
Dim strUser, strPassword, strDomain, strOU
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
' Declare domain and the OU
strDomain = "mydomain.com"
strOU = "OU=FloorGroup,OU=ShopFloorAccounts,OU=City,OU=Americas,DC=domain,DC=com"
strUser = "user"
strPassword = "password"
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, _
JOIN_DOMAIN)
If Not ReturnValue = 0 Then ' if the joining fails
Wscript.Echo "Joining machine to the domain has failed. Please try again"
Wscript.Echo "Error Number: " & Err.Number
Wscript.Echo "Error Description: " & Err.Description
Wscript.Quit
Else
Wscript.echo "Machine has joined the domain successfully. Please click OK to reboot"
END If
WScript.sleep(5000)
' More code to add autologin reg entries
Before we created all the machine names in AD I could make this work (with options 1 & 2). However it will always fail if the computer account is already created in AD. I have tried literally dozens of different permutations of domain join scripts, and nothing seems to work correctly.
How I am using this script: This is part of a setup routine for touchscreen computers on the shop floor. The computers are all currently in "Workgroup", however we want to move them over to the domain. This setup routine will also be used to make swapping out a terminal simpler in case a machine fails.
The machine setup process: From a generic ghost image, I set up the individual station and rename it using a HTA. This script is copied over to the root of the drive, and called via runonce key that will execute after the reboot from the name change.