SCCM Task Sequence – Ask for Computer Name

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!

Downloads

Scripting

First, save the following source as “PromptForSystemName.vbs”. It’s modified version of the script from t3chn1ck’s wordpress blog post found here: PromptForSystemName vbScript.
'==========================================================================
' 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, http://windowsmasher.wordpress.com
WinMove("Installation Progress", "", 0, 0)

If WinExists("Computer Name") Then
	$pos = WinGetPos("Computer Name")
	WinMove("Computer Name", "", $pos[0], ($pos[1]+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

  1. Open the Task Sequence that needs to ask for the computer name.
  2. 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

Notes

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.

About these ads

5 thoughts on “SCCM Task Sequence – Ask for Computer Name

    • Thanks for writing this script! It works great. As for the progress box, I can’t use the easier solution because I don’t want to completely close the UI, just move it to the top-left corner.

  1. Hi,

    I”m trying to import this in to an SCCM 2012 TS. It’s almost what I need for my deployment.
    The only problem is it fails with error 0x00000001, Incorrect Function. Do you have an idea what the problem could be?

    Also is it possible to prompt the current hostname instead of saying it should be changed?
    This is because we are going to migrate a customer, but some pc names are wrong.
    We don’t want to chance all computer with the OSDComputerName Variable. Your script should bring the solution. Show hostname -> Is it right, continue. Is it wrong, change. We are trying using known and unknown devices. All Devices start with the same 3 letters. So I added a line to prompt if it start with those letters.

    A lot of questions, sorry for that. Hope you can help me.

    Regards,

    Anne

  2. Pingback: Table of Contents | windowsmasher

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s