Back in 2012 I wrote an article about dynamically setting a computer name during a Task Sequence. Here is my updated and improved script..

I’m currently setting up a deployment solution running SCCM with MDT 2013. 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.

Part of this solution was to manage the clients names. We decided to use the ethernet MAC-address as an identifier. The script collects the last 7 characters (without dashes) from the MAC-address (UUID), and sets it as the OSDComputerName.

Dim env, MyUUID
Set env = CreateObject("Microsoft.SMS.TSEnvironment")
MyUUID = Right(Replace(env("UUID"),"-",""),7)

If env("IsDesktop") = "True" Then
	env("OSDComputerName") = "D" & MyUUID
Elseif env("IsLaptop") = "True" Then
	env("OSDComputerName") = "L" & MyUUID
End If

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! :)