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


0 Comments   [ + ] Show comments

Answers (3)

Answer Summary:
Posted by: SMal.tmcc 4 years ago
Red Belt
the join domain vbs file was supplied with kace, in case you do not have it on your kbox here is the code

Const JOIN_DOMAIN             = 1
Const WIN9X_UPGRADE = 16

strDomain = "your.domain.name"

WScript.StdOut.Write("Enter Authorized User ")
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, _

Posted by: jayrobinson 4 years ago
Yellow Belt
I have always found that..if you want to use the same computer name, you need to delete the old computer object in active directory then during the imaging process, you can use the get/set computername for the same name.

This way you will generate a nice new SID for the computer object.

  • 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 4 years ago
    • Thank you for clarification on this. - si1974 4 years ago
Posted by: SMal.tmcc 4 years ago
Red Belt

Top Answer

the best thing to do is use the get/set computer name app provided by Kace (can be found under the Tools menu on the K2.

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

  • 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 4 years ago
  • Thank you for this details answer, this looks to be just what I need, very much appreciated. Kind regards - si1974 4 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 4 years ago
      • Thanks for the tip - si1974 4 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