Jump to content


tmiller_hockey

Name Computer To Serial Number During OSD

Recommended Posts

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?

Share this post


Link to post
Share on other sites


You can indeed just run your own custom script from a package or commandline in the task sequence, or you can use the builtin options from MDT for that. If you have MDT integrated, you can use the Gather step to get you a new variable called AsstTag.

Share this post


Link to post
Share on other sites

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.

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

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.

 

'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

Share this post


Link to post
Share on other sites

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

Share this post


Link to post
Share on other sites

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.

Share this post


Link to post
Share on other sites

I do have MDT Installed but for right now I'm sticking with my vbs script as when our machines are imaged, they usually know what structure for naming to use. We use this for a naming scheme:

 

APPENDING ABBREVIATION-SERIAL-TYPE OF MACHINE (Student Or Teacher) Would look something like this. SGP-L3RV323-T

 

The script I use now pops up an inputbox that asks for the Appending and the machine type and automatically pulls the serial.

 

I know this can be done in MDT using an HTA but have no clue how to do it.

Share this post


Link to post
Share on other sites

Hi

 

I do not have MDT at present and want to rename from TS

 

How do I do this? its windows 7..

 

This thread seems to jump between scripting and MDT

 

thanks

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.

Guest
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.

Loading...

×
×
  • Create New...