Prompt for PC Name during Task Sequence


During a TS Deployment, the client will query the DP and check if the resource has a Machine Name (OSDComputerName) and sets the _SMSTSMachineName Task Sequence variable which is used to name the PC during deployment.

In our environment, we import the PC information in the console first, then deploy the TS to the collection the newly imported device is a member of. However, if you have a fresh machine and a TS deployed to the Unknown Computers collection, you can set the PC Name during the Task Sequence itself.

Because our Task Sequence is used to reimage offsite PCs from a cold-boot (using USB) we first check to see if we can query the DP and obtain the Machine Name with the following Powershell Script:

PowerShell -ExecutionPolicy Bypass -Command "(New-Object -COMObject Microsoft.SMS.TSEnvironment).Value('OSDComputerName') = '%_SMSTSMachineName%'"

If we can, the _SMSTSMachineName is set to the queried value in OSDComputerName – if not, the _SMSTSMachineName remains the generic minint or minwinpc value.

Queue the VBS!

Create a package (without a program) to house a VBS Script. This script will be called during the Task Sequence and check if the _SMSTSMachineName variable exists and what it is.

If the value is either minint or minwinpc , the script will prompt the end-user to enter a value to be set as the _SMSTSMachineName.


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
   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
   wscript.echo "Computer set to receive a standard name, continuing as is."
End If

And there you have it – the PC name is set by user-input during the TS Deployment. This can be very helpful for onboarding new devices or, in our case, imaging PCs when connectivity to the SCCM Server is unavailable in windows PE/RE.

Let me know if I am helping.

Was this helpful?

More to explorer

Updating Scheduled Task (accounts) Remotely

It’s that time of year – for me, anyway – the time of year when all of our Domain Service Account(s) passwords expire, and for me that means changing dozens of scheduled task RunAs accounts.

Switch Port Discovery Tools

Have you ever been out in the field and needed to know what port a device is plugged into? Perhaps you cannot

Leave a comment

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