How to generate random computer names for lab deployments using SCCM OSD

For my lab environment I use the below described approach to generate random computernames for my clients. The script does the following:

  1. Read the Task Sequence Package Name
  2. Based on the name set the appropriate prefix
  3. Generate a random number between 100 and 1000
  4. Generate the new computer name based on Prefix + random number

To implement this do the following:

  1. Put the script listed below into a package
  2. Add the script to the TS by adding a Run Command Line task after Partition Disk and before Apply Operating Systemimage

 

Script: OSDComputername.vbs

 

[sourcecode language=”vb”]
Set env = CreateObject("Microsoft.SMS.TSEnvironment")
tsname = env("_SMSTSPackageName")

select case tsname
case "Deploy Windows 7 sp1 x64"
Prefix = "Win7"
case "Deploy Windows 8 x64"
Prefix = "Win8"
case else
Prefix = "CL"
end select

env("OSDComputerName") = RCompName()

Function RCompName()
On Error Resume Next
Dim CompName : CompName = ""
Dim max,min
max=1000
min=100
Randomize
CompName = "" & Prefix & (Int((max-min+1)*Rnd+min))
oLogging.CreateEntry "Generated random Computername ‘" & CompName & "’", LogTypeInfo
RCompName = CStr(CompName)
End Function

[/sourcecode]

Leave a Reply

Your email address will not be published. Required fields are marked *