Deployment Solution

 View Only
Expand all | Collapse all

Sysprep computer name

SK

SKFeb 04, 2014 02:21 PM

  • 1.  Sysprep computer name

    Posted Jan 27, 2014 01:00 PM

    New to 7.5 and I need to be able to configure the computer name in the sysprep file. We have a large number of new computers earch year that aren't in the deployment database. I've read some stuff online but haven't found an exact solution to this. So how can I change the computer name in the sysprep file after the image is deployed?



  • 2.  RE: Sysprep computer name

    Posted Jan 27, 2014 01:33 PM

    The sysprep file can be populated via tokens, which means that the computer name thzat you want needs to be in the database before the imageing process, so your best bet will probably be to use the predefined computers list.

    If you dont want the machines to be in the database until after the imaging process, then you will need to use a post configuration task to change the machine names once they have been imaged manually; however, if you are imaging large numbers of machines each time, then to use tokens with that task (I dont know if you can or not) would mean that a machine name list would need to exist in the database anyway.



  • 3.  RE: Sysprep computer name

    Posted Jan 27, 2014 02:46 PM

    Yeah I'd really like to set the name correctly the first time without pre-loading the computers. We name the computers the serial number of the computer, I've seen different posts about users using a script to pull this and then inserting it into the sysprep file. Any idea on how to do that?



  • 4.  RE: Sysprep computer name

    Posted Jan 29, 2014 09:50 AM

    Is this any good ?

    I use this script after ghost has run and before reboot to production - it prompts for a hostname and updates the unnatend file with it. 

    *update the unattend file to have _COMPUTERNAME_REPLACE_

     

    Option Explicit
     Dim answer, computerName, unattendFile, WshShell, fso, unattendFileObject, strContents

    unattendFile = "D:\windows\Panther\unattend.xml"
     
     Set WshShell = WScript.CreateObject("WScript.Shell")
     Set fso = CreateObject("Scripting.FileSystemObject")
     
     Do While answer <> vbYes
        computerName = InputBox("Enter the desired Computer Name:", "Computer Name")
        answer = MsgBox("Is this correct?" & vbCrLf & "Computer Name: " & computerName, vbYesNo, "Verify Name")
     Loop
     
     If fso.FileExists(unattendFile) = False Then
        wscript.echo "ERROR: Could not find the unattend file"
     Else
        'Read the unattend file in and replace apprpriate variables
        Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
        strContents = unattendFileObject.ReadAll
        strContents = Replace(strContents, "_COMPUTERNAME_REPLACE_", computerName)
        unattendFileObject.Close
     
        'Write the updated contents back to the unattend file
        Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
        unattendFileObject.Write(strContents)
        unattendFileObject.Close
     End If



  • 5.  RE: Sysprep computer name

    Posted Jan 29, 2014 04:23 PM

    I can't enter the names in manually, that would take forever for the number we do. I wonder if you could query the smbios in this script instead?



  • 6.  RE: Sysprep computer name

    Posted Jan 29, 2014 04:56 PM
    If I modified your script like this do you think it would work?
     
     
    Option Explicit
    Dim answer, computerName, unattendFile, WshShell, fso, unattendFileObject, strContents, strComputer, objWMIService, colSMBIOS, objSMBIOS
    strComputer = "." 
    Set objWMIService = GetObject("winmgmts:" _ 
        & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2") 
     
    Set colSMBIOS = objWMIService.ExecQuery _ 
        ("Select * from Win32_SystemEnclosure")
     
    For Each objSMBIOS in colSMBIOS    
     
    unattendFile = "C:\windows\Panther\unattend.xml"
      
      Set WshShell = WScript.CreateObject("WScript.Shell")
      Set fso = CreateObject("Scripting.FileSystemObject")
      
      If fso.FileExists(unattendFile) = False Then
         wscript.echo "ERROR: Could not find the unattend file"
      Else
         'Read the unattend file in and replace apprpriate variables
         Set unattendFileObject = fso.OpenTextFile(unattendFile, 1)
         strContents = unattendFileObject.ReadAll
         strContents = Replace(strContents, "_COMPUTERNAME_REPLACE_", objSMBIOS.SerialNumber)
         unattendFileObject.Close
      
         'Write the updated contents back to the unattend file
         Set unattendFileObject = fso.OpenTextFile(unattendFile, 2)
         unattendFileObject.Write(strContents)
         unattendFileObject.Close
      End If
     
       
    Next 
     


  • 7.  RE: Sysprep computer name

    Posted Jan 30, 2014 04:02 AM

    Can you not Apply system configuration in a job which renames it to the serial number using a token ?



  • 8.  RE: Sysprep computer name

    Posted Jan 30, 2014 06:39 AM

    If that was possible it would be a good method to use.



  • 9.  RE: Sysprep computer name

    Posted Jan 30, 2014 08:48 AM

    So will this script work or not and what does the job need to look like to make this work?



  • 10.  RE: Sysprep computer name

    Posted Jan 30, 2014 10:59 AM

    According to the Deployment Solution User Guide it is.

    "For computer names, you can use tokens. For example, %CustomerToken%, %SERIALNUMBER%."

     



  • 11.  RE: Sysprep computer name

    Posted Jan 30, 2014 11:31 AM

    That is just if the computers are in the database though



  • 12.  RE: Sysprep computer name

    Posted Jan 30, 2014 11:45 AM

    If the build job completes and a inventory has been sent then surely it would work then ?

     



  • 13.  RE: Sysprep computer name

    Posted Jan 30, 2014 11:47 AM

    so I would have the job like this

    deploy image
    reboot
    send inentory (if even needed)
    Apply system configuration job with serial number token.
     

    Would that not work!

     



  • 14.  RE: Sysprep computer name

    Posted Jan 30, 2014 12:08 PM

    But not all computers get the agent so inventory wouldn't be done. Would your script that I updated not work?



  • 15.  RE: Sysprep computer name

    Posted Jan 30, 2014 01:35 PM

    Sorry - I'm not a scripter - I got the script from another site.



  • 16.  RE: Sysprep computer name

    Posted Jan 30, 2014 03:19 PM


    Ok well I know it works but not sure how it will work in the process. So would the job just have the deploy job and then the next step is this script?



  • 17.  RE: Sysprep computer name

    Posted Jan 31, 2014 04:01 AM

    Yep,

    Deploy Image
    Run Script task
    Reboot to production

    That should do it.

     



  • 18.  RE: Sysprep computer name

    Posted Feb 04, 2014 08:41 AM

    the utility that renames a PC to serial number is WSNAME.exe - google it.

    this should save you scripting. stick it in a copy job then run.

     



  • 19.  RE: Sysprep computer name

    Posted Feb 04, 2014 02:21 PM

    Nice.