Jump to content


Name Computer To Serial Number During OSD

Recommended Posts

We set the PC name of a predefined site code with serial number. See below for the VB section of our HTA:


' Run the WMI query to find the current serial number of the machine
 Set WMI = GetObject("WinMgmts:")
 Set colSerialNumbers = WMI.InstancesOf("Win32_BaseBoard")
 For Each objSerialNumber In colSerialNumbers
  sComputerName = sComputerName & objSerialNumber.SerialNumber

 ' Pass our variables back to the Task Sequence so that they can be used.
 oTaskSequence ("OSDDomainOUName") = sLDAP
 oTaskSequence ("OSDTimeZone") = sTimeZone
 sComputerName = sSiteCode & "-" & sComputerName
 oTaskSequence ("OSDComputerName") = sComputerName

 ' Close the window seeing as we are finished with this HTA.

End If
End Sub


Hope this helps. You need to first get the serialnumber from a WMI query. Then you need to set the TS Variables and pass them back to the task sequence. There's a lot of examples online.

Share this post

Link to post
Share on other sites

I have a VBS script already that works running on a local machine and passed via Altiris to a machine. I just need to know how to get this script to run and where to put it in the task sequence.


' vbscript
'  Declare Variables
Dim strLocation
Dim strSerialNum
Dim strAppend
Dim strComputerName
Dim strLclUser
Dim strLclPW
Dim strComputer
Dim objWMIService

Dim objComputer

' Set Variables
strLclUser = "Administrator"
strLclPW = "password"

' Obtain Serial Number
strComputer = "."
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")
Set colSMBIOS = objWMIService.ExecQuery("Select * from Win32_BIOS")

For Each objSMBIOS in colSMBIOS
strSerialNum = objSMBIOS.SerialNumber

' Set Computer Name
strComputerName = strSerialNum 

' Rename Computer
For Each objComputer in objWMIService.InstancesOf("Win32_ComputerSystem")
       Return = objComputer.Rename(strComputerName, strLclUser, strLclPW)

       If Return <> 0 Then
          WScript.Echo "Rename failed. Error = " & Err.Number
          WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
       End If


Share this post

Link to post
Share on other sites

I figured this out in a very simple way with a very short script.


Insert into TS right after Partition Disk.


set env = CreateObject("Microsoft.SMS.TSEnvironment")
Set ProgressUI = CreateObject("Microsoft.SMS.TsProgressUI") 
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
env("OSDComputername") = objItem.SerialNumber

Share this post

Link to post
Share on other sites



Sorry no one has reponded -- CustomSettings.ini requires MDT (Microsoft Deplyment toolkit) -- you can download/install it (about 22MB) then go to:


This shows how to Integrate MDT with SCCM (Super Easy)!!


I am personnaly VERY New to SCCM and giving the above steps a go.

Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.