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

Answer Summary:
Cancel
0 Comments   [ + ] Show Comments

Comments

Please log in to comment

Answer Chosen by the Author

0
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






Answered 05/10/2016 by: SMal.tmcc
Red Belt

  • 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
  • Thank you for this details answer, this looks to be just what I need, very much appreciated. Kind regards
    • 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 *
      • Thanks for the tip
Please log in to comment

Answers

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

Answered 05/11/2016 by: SMal.tmcc
Red Belt

Please log in to comment
1
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.
Answered 05/11/2016 by: jayrobinson
Senior White Belt

  • 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
    • Thank you for clarification on this.
Please log in to comment
Answer this question or Comment on this question for clarity
Admin Script Editor
Admin Script Editor is an integrated scripting environment available free here at ITNinja

Share