Rename machine to Serial during task sequence
Looking fo a little assistance. i have SCCM SP2 all setup and i can run a task sequence on an unknown machine and it all runs through fine and the machine is joined to the domain by the end of the process. what we are trying to do now is to rename the machine to the serial number of the machine. i have done a search and found software called wsname.exe which others seem to have used succesfully but i just cant seen to get it right. we have tried using wsname /N:$SERIALNUM as a command line after the windows setup but befor the joining to the domain but that didnt work as it dosent seem to run with the correct permissions. we have also tried running the comman wsname /n:mynewname /rcid /user:mydomain\administrator /pass:secret with the relevent details and put this after a reboot after joining domain and we get and application error. can anyone help me out as we need this done before all our new HP Machines get here. Thanks Adam
September 3rd, 2010 10:24am

Just a quick question: why name your computers after the serial number? SCCM will (probably) inventory this for you and keep it in its database.Kind regards Tim Nilimaa IT Consultant at Mindgrape (Sweden) Please remember to mark this answer as helpful if it helped you.
Free Windows Admin Tool Kit Click here and download it now
September 3rd, 2010 4:37pm

Just a quick question: why name your computers after the serial number? SCCM will (probably) inventory this for you and keep it in its database. Kind regards Tim Nilimaa IT Consultant at Mindgrape (Sweden) Please remember to mark this answer as helpful if it helped you. we will be using some netbooks and booking them in and out to people using the serial numbers, using this system we would know which machine is out to which person so it just makes sense to us that the machine name should be the same. does anyone have any guide on using the wsname.exe software at all?
September 6th, 2010 3:03am

Set env = CreateObject("Microsoft.SMS.TSEnvironment") Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password) Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48) For Each objItem in colItems objItem.SerialNumber=env("OSDComputername") Next _________________________ Just run this script after the deploye OS step. It will set the SCCM variable "OSDComputername" to serial, and the rest vill take care of it self... Michaelhttp://kongkuba1.spaces.live.com
Free Windows Admin Tool Kit Click here and download it now
September 6th, 2010 2:41pm

Set env = CreateObject("Microsoft.SMS.TSEnvironment") Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password) Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48) For Each objItem in colItems objItem.SerialNumber=env("OSDComputername") Next _________________________ Just run this script after the deploye OS step. It will set the SCCM variable "OSDComputername" to serial, and the rest vill take care of it self... Michael http://kongkuba1.spaces.live.com OK please bear with me on this, the script looks like it will do what i want. When i setup the task sequence it partitions the drive, loads the wim image file and then i create a new comand line and get it to run this as a vb script or something else?? i am new to all this SCCM stuff so i appreciate the time and effort you guys are giving this.
September 7th, 2010 6:59am

yes. make it a .vbs, and add it to a package. Add the Run commandline step just after you load the wim. Make sure to use the package in the step and run the script by writing cscript.exe xxxx.vbs. That it Michaelhttp://kongkuba1.spaces.live.com
Free Windows Admin Tool Kit Click here and download it now
September 7th, 2010 9:39am

Created a package for the script and added a command line after OS apply and before appy windows settings with command line cscript.exe xxxxx.vbs but it doesnt apply the hostname as serial number instead it takes deafult name like MININT-XXXXX and installed all tasks actions without any issue. Looking into smsts.log for more info //Eswar Koneti @ http://eskonr.wordpress.com/
October 14th, 2010 12:14pm

Set env = CreateObject("Microsoft.SMS.TSEnvironment") Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator") Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password) Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48) For Each objItem in colItems objItem.SerialNumber=env("OSDComputername") Next _________________________ Just run this script after the deploye OS step. It will set the SCCM variable "OSDComputername" to serial, and the rest vill take care of it self... Michael http://kongkuba1.spaces.live.com I'm not sure if anyone has noticed this yet but the script is actually slightly incorrect: For Each objItem in colItems objItem.SerialNumber=env("OSDComputername") Next The above is trying to set the WMI object objItem.SerialNumber to equal the value returned by env("OSDComputername"). But this won't actually set the target computer name because it needs to set the Task Sequence Environment Variable - so it should be the other way round. For Each objItem in colItems env("OSDComputername") = objItem.SerialNumber Next Ben http://www.avida.com.au
Free Windows Admin Tool Kit Click here and download it now
January 21st, 2011 2:21pm

you are correct.. sorry for that Michaelhttp://kongkuba1.spaces.live.com
January 21st, 2011 2:38pm

I've actually discovered some other issues. Windows doesn't allow you to use only numerical values as the computer name. Some serial numbers (E.g. Lenovos) have only a numerical value. Then there is also the case of Windows doesn't allow you to have a NETBIOS name longer than 15 characters and you can't have spaces - in the case of building VM's using OSD, these can not only be a long string of characters which look something like MAC addresses, but they also have spaces - e.g.: 1274-4563-1345-7338-2456-0325-82 Here is a script whcih takes some of these into consideration: On Error Resume Next Dim objWMIService Dim colItems Dim colBattery Dim objSMSEnv Dim strNewName Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Bios") Set colBattery = objWMIService.ExecQuery("SELECT * FROM Win32_Battery") ' Get the Serial Number For Each objItem In colItems ' Remove all beginning, trailing and containing spaces and change to all upper case strNewName = UCase(Trim(Replace(objItem.SerialNumber, " ", ""))) Next ' Is this a Desktop or a Laptop If colBattery.Count = 1 Then ' Is a Laptop strNewName = "L" & strNewName Else ' Is a Desktop strNewName = "W" & strNewName End If ' If the name is longer than 15 characters, we need to truncate it If Len(strNewName) > 15 Then ' If the name contains "-" characters (e.g. VM's), remove them If InStr(strNewName, "-") > 0 Then strNewName = Replace(strNewName, "-", "") End If ' If the name is still longer than 15 characters, truncate it to first 15 strNewName = Mid(strNewName, 1, 15) End If ' Set the Environment Variable that controls the Computer Name Set objSMSEnv = CreateObject("Microsoft.SMS.TSEnvironment") objSMSEnv("OSDCOMPUTERNAME") = strNewName Set objSMSEnv = Nothing Set colItems = Nothing Set colBattery = Nothing Set objWMIService = Nothing Taken from http://www.2way.net.au/blog/post/2011/01/21/OSD-Task-Sequence-Set-Computer-Name-to-Serial-Number.aspx Ben
Free Windows Admin Tool Kit Click here and download it now
January 21st, 2011 4:11pm

thanks ben, this script really hekped me to name my machine using SCCM 2007... currently testing it with MDT 2010 TS....will update soon... thanks pranay.
September 1st, 2011 7:15am

just as an update.... the script is working fine with MDT 2010...after few changes i figured out that we need to put the script and declare a task sequence variable as OSDCOMPUTERNAME after the first initializing phase of the task sequence.... In SCCM 2007 i just put the script after the apply OS phase in the task sequence. It worked like a charm. thanks Pranay.
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2011 12:42am

Thanks Pranay, Its great and it worked for me too...............Gaurav Ranjan
September 2nd, 2011 2:11am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics