One of the first things I needed to do after starting the SCCM trek was to ask for the computer name in a deployment task sequence. It’s not that bad; follow along!
'========================================================================== ' 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 oShell = WScript.CreateObject ("WScript.shell") sExpression = "move-installationprogress.exe" oShell.Run sExpression 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") oTaskSequence("OSDComputerName") = UCase(sNewComputerName) wscript.echo "Set Task Sequence variable OSDComputerName to: " & sNewComputerName Else wscript.echo "Computer set to receive the standard name """ & sTSMachineName & """, continuing as is." End If
Next, save the following source as “move-installationprogress.au3″. Download and Install AutoIt, then right-click and compile the au3 script to an x64 executable.
;Move-InstallationProgress.au3, John Puskar, https://windowsmasher.wordpress.com WinMove("Installation Progress", "", 0, 0) If WinExists("Computer Name") Then $pos = WinGetPos("Computer Name") WinMove("Computer Name", "", $pos, ($pos+50)) EndIf Exit
Create a new package named “Scripts – Ask for Name”, then copy both the vbscript and the executable to the source folder of this package.
Putting things together
- Open the Task Sequence that needs to ask for the computer name.
- Create a new TS Run Command-Line Action with the following parameters.
Name: Ask for Computer Name Command: PromptForSystemName.vbs Package: Scripts - Ask for Name
It’s important to note that the vbscript will only ask for a name if the computer is ‘unknown’, meaning that it’s not in the SCCM database. If you’d like it to prompt no matter what, you’ll need to modify the script.
Thanks! As usual, please let me know if you find a problem or a more creative solution.