Skip to content

Name Computer To Serial Number During OSD

Featured Replies

Anyone know of an easy way to name a computer to its serial number during OSD?

 

I have a vbs script that I used under Altiris but how/where would I inject this script during OSD?

  • 2 weeks later...
  • Author

I'm trying to figure out exactly where to inject this into the task sequence. So far no luck with where I've put it.

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
 Next

 ' 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.
 window.close

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.

  • Author

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
Next

' 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
       Else
          WScript.Echo "Rename succeeded." & " Reboot for new name to go into effect"
       End If

Next

  • Author

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

 

Insert into TS right after Partition Disk.

 

'vbscript
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
Next

you could simply set this in customsettings.ini then it will apply to all task sequnces ==> OSDComputername=%SerialNumber%

  • 1 month later...

tmiller_hockey,

 

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

http://blogs.technet.com/b/anilm/archive/2012/05/06/integrating-mdt-2012-rtm-with-configuration-manager-2012-rtm-part-2-configuring-integration.aspx

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

 

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

Join the conversation

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

Guest
Reply to this topic...

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.