I got this working if anyone is interested:
Dim objWMIService Dim colItems Dim colBattery Dim objSMSEnv Dim strNewName Const strSite = "Tablet"
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2") Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Bios") Set colBattery = objWMIService.ExecQuery("SELECT * FROM Win32_Battery")
' Get the Serial Number For Each objItem In colItems ' Remove all beginning, trailing and containing spaces and change to all upper case strNewName = UCase(Trim(Replace(objItem.SerialNumber, " ", ""))) Next
strNewName = Right(strNewName, 5)
'Site Code + Last 5 of Serial Number strNewName = strSite & strNewName
' Set the Environment Variable that controls the Computer Name Set objSMSEnv = CreateObject("Microsoft.SMS.TSEnvironment") objSMSEnv("OSDCOMPUTERNAME") = strNewName