New Image using Attach to domain using existing host name
Dear all,
I am used to rolling out new images but generally I then have to give it a hostname, add it to the domain etc.
I am currently engaged on a project to create a new image to deploy across the firm, but this want to try and achieve the following:
1) Boot up PC via WOL
2) Take note of the current hostname
3) Image the PC
4) Attach to our network domain using the current hostname attributed to each device.
Does anyone have any best practise or knowledge on this as I am not really sure where to start.
Also, does anyone have any experience whereby once the pc has been attached to the domain with the existing hostname does it add it to active directory in the same OU it came from or does this have to manually be done.
Kind regards in advance
Simon
Answers (3)
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
strDomain = "your.domain.name"
WScript.StdOut.Write("Enter Authorized User ")
WScript.StdIn.Read(0)
strUser = WScript.StdIn.ReadLine()
Set ScriptPW = CreateObject("ScriptPW.Password")
WScript.StdOut.Write("Enter password ")
strPassword = ScriptPW.GetPassword()
WScript.StdOut.WriteLine ""
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:
-
You do not need to delete the computer name from AD. We are a College. We image 2000+ systems at least twice a year and have never done that. Syspreping a machine releases the SID, it then gets a new SID post. When it joins the domain it updates the existing machine object with the new info. You just have to make sure the user joining the machine has the proper rights to modify an existing machine object as well as delete and create - SMal.tmcc 8 years ago
-
Thank you for clarification on this. - si1974 8 years ago
Top Answer
You create a pre task just prior to reformatting the drive to get the current name and use the set as a mid task to place it in the new image and as a post task use the join domain VBS to rejoin the newly imaged pc to the domain
Comments:
-
if the name is already in the domain it will leave it in it that OU. On the Academic side we actually precreate any new names in the domain prior to imaging and then use a prompt for computer name and use the new names we assigned. the above script collects the current name and reapplies it then joins the domain leaving the machine in the OU - SMal.tmcc 8 years ago
-
Thank you for this details answer, this looks to be just what I need, very much appreciated. Kind regards - si1974 8 years ago
-
just make sure you have <computername>*</computername> in your answer file. the setname takes what is mined from the get command and then searches the answer file for <computername>*</computername> and replaces that with the name in place of the * - SMal.tmcc 8 years ago
-
Thanks for the tip - si1974 8 years ago