When doing a baremetal image in SCCM OSD, the task sequences will generate a random name for the system. To define a specific name the system is to receive, use the following VBScript. It will prompt the end-operator to input a name and then it will set the TS variable “OSDComputerName”.
Add the script to the TS by adding a Run Command Line task after Partition Disk and before Apply Operating System.
’========================================================================== ‘ NAME: PromptForSystemName.vbs ‘ ‘ AUTHOR: Nick Moseley ‘ DATE : 6/1/2009 ‘ ‘ COMMENT: This script will detect if the current assigned value for the computer name ‘ begins with MININT, indicating that this image is bare metal image. It then prompts ‘ the end-user to enter a new computer name. ‘ ‘ VERSION : 1.1 ‘ 1.0 (12/08/2008)- Intial script to check if the computer name begins with ‘ “minint”, which indicates the system was booted with CD or PXE. ‘ 1.1 (06/01/2009)- Added check if the computer name equals “minwinpc”, ‘ which indicates the system was booted with USB key ‘==========================================================================
Dim sNewComputerName, oTaskSequence, sTSMachineName, bPromptName Set oTaskSequence = CreateObject (“Microsoft.SMS.TSEnvironment”)
’ Get the name the computer is set to receive and truncate to first 6 letters sTSMachineName = lcase(oTaskSequence(“_SMSTSMachineName”)) If left(sTSMachineName,6) = “minint” Then bPromptName = True ElseIf sTSMachineName = “minwinpc” Then bPromptName = True Else bPromptName = False End If
’ Note: The wscript.echo commands are logged in SMSTS.log for troubleshooting. They are not displayed to the end user. If bPromptName = True Then wscript.echo “Detected that the computer name is scheduled to receive a random value. Prompting user to input a standard name.” sNewComputerName = InputBox (“Please enter a standard computer name to continue.”, “Computer Name”, , 30,30) oTaskSequence(“OSDComputerName”) = UCase(sNewComputerName) wscript.echo “Set Task Sequence variable OSDComputerName to: “ & sNewComputerName Else wscript.echo “Computer set to receive a standard name, continuing as is.” End If