An updated article with a new script found here!

I’m currently setting up a Deployment solution based on System Center Configuration Manager 2012 intregrated with MDT 2012. The idea was to set up a User Driven Installation (UDI) so the IT department would have to do as little as possible during the installation process.

Users would supply their corporate information during the initial steps of the installation and everything else would be taken care of.

Part of this solution was to manage the clients names, we decided to use the serial number as an identifier.
Primarily because it made sense to use the same identifier for all systems (HP/Dell use serial number not “LAPTOP00212”).

It’s a rather simple script which selects the last 10 characters of the serial number and remove the dashes.
Without this correction (shortening and removing special characters) the installation with halt on virtual machines due to the generated serial numbers (very long)..


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
	env("OSDComputerName") = Right(Replace(objItem.SerialNumber,"-",""),10)

Save the script in your MDT package under the Scripts-folder:

Update the DP’s and head over to your Task Sequence.
Scroll down to PostInstall and under Gather add a Run Command Line-step.
In the Command line box type:

cscript.exe "%deployroot%\scripts\SetComputerName.vbs"

Deploy and ENJOY! :)