Jump to content


  • 0
anyweb

Setting computername during deployment

Question

how to prompt for Computername during OSD

 

If you want to be prompted for the computername during a deployment (works for the R2 release of SCCM 2007) try the following

 

on your deployment collection, right click and choose modify collection settings

 

create a new variable called OSDComputerName and leave it blank

 

Advertise your task sequence to this collection, but make sure that the Task Sequence is not set to mandatory

 

now, when the Task Sequence executes it will prompt you for the computername during OSD, cool huh ? click on the variable when you see it and enter your desired computername..

 

 

 

Can I script it ?

 

oh and here's another way from the very talented Michael in Denmark smile.gif

 

easy way to change PC name during Deployment

 

and here's a script sample

 

Set env = CreateObject("Microsoft.SMS.TSEnvironment")
Set SWBemlocator = CreateObject("WbemScripting.SWbemLocator")
Set objWMIService = SWBemlocator.ConnectServer(strComputer,"root\CIMV2",UserName,Password)
Set colItems = objWMIService.ExecQuery("Select * from Win32_BIOS",,48)
For Each objItem in colItems
 env("OSDComputerName") = objItem.SerialNumber
next

 

_________________________

 

Just run this script after the Deploy OS step. It will set the SCCM variable "OSDComputername" to the serial, and the rest will take care of it self...

 

 

Related reading:-

 

here's the Technet version of the same

Share this post


Link to post
Share on other sites

Recommended Posts

  • 0

I am struggling a bit here and would like to ask for a bit of advice.

 

I am currently deploying images to machines via dvd media (using my test lab) as our live sccm is still at planning stage. The dvd gets shipped with the machine to our remote sites enabling our power users to rebuild without my intervention.

 

Some apps at the end of the task sequence rely on the pc being named correctly so at some point I need the task sequence to halt and prompt for a PC name. The PC name will not be in the bios as its using a company naming convention so need to be a free form input.

 

How can I achieve this?

Share this post


Link to post
Share on other sites

  • 0

Found the solution:

 

Create a package with the following VBScript:

 

----------------------------------------------------------------------------------------------------------

 

 

set env = CreateObject("Microsoft.SMS.TSEnvironment")

 

Name = inputbox("Rename Computer" ,"Please enter the new Computer name below:",env("_SMSTSMachineName"),400,0)

 

env("OSDComputerName") = Name

 

-----------------------------------------------------------------------------------------------------------

Add a "Run command line" step to your Task Sequence, and run the script (put this step right after the "format and partition disk").

 

This will display pop-up box for you to enter the new computer name.

 

 

 

Hope this helps - works in my lab

Share this post


Link to post
Share on other sites

  • 0

I followed a similar approach but took it a step further. We found that the task sequence would fail to join machines to our domain due to invalid characters or computer names that were too long. I threw in some error checking from some other scripts I found online and made a few tweaks. It will pre-populate the field if it has a known computer name and also does some logging smsts.log

 

I also have one for filling in the computer description which we use for inventory if anyone else is interested in that.

 

Dim objRegEx
Dim Matches, Match
Dim strPattern, sNewComputerName, strReason
Dim boolLength, boolValid
Dim oTaskSequence, sTSOldName
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set objRegEx = New RegExp
' Define valid patterns as a character not in (a-z, A-Z, 0-9, or -)
strPattern = "[^a-zA-Z0-9-]"
' Get old computer name, or random name if unknown
sTSOldName = oTaskSequence("_SMSTSMachineName")
' The wscript.echo commands are logged in SMSTS.log for troubleshooting.
' They are not displayed to the end user.

Do
strReason = ""
sNewComputerName = InputBox ("Enter desired computer name." & VbCrLf & VbCrLf & "Computer names must be 3-14 characters, and include a-z, A-Z, 0-9, -, and _ ONLY.","Computer Name",sTSOldName,,30)

' Check length - must be less than 16 charatcers
If Len(sNewComputerName) <= 15 Then
 boolLength = True
Else
 strReason = strReason & "Computer name too long. Please choose a name from 1-15 characters in length." & VbCrLf
 boolLength = False
End If

' Check character validity
boolValid = True
' Return all matches for invalid characters
objRegEx.Global = True
objRegEx.Pattern = strPattern
' Generate collection of matches
Set Matches = objRegEx.Execute(sNewComputerName)
' Check for matches on invalid characters
For Each Match In Matches
 strReason = strReason & "Invalid character """ & Match.Value & """ found. Please use only a-z, A-Z, 0-9, and -." & VbCrLf
 boolValid = False
Next
If Not (boolLength And boolValid) Then MsgBox "Invalid name """ & sNewComputerName & """ entered!" & VbCrLf & VbCrLf & strReason,vbCritical+vbOKOnly+vbSystemModal,"Invalid Name Entered"
Loop While Not (boolLength And boolValid)

oTaskSequence("OSDComputerName") = sNewComputerName
wscript.echo "Set Task Sequence variable OSDComputerName to: " & sNewComputerName

  • Like 1

Share this post


Link to post
Share on other sites

  • 0

I have modified a version of the following computer rename script. Details of the edit can be found in the header of the script, however this script will not allow blank input and does a check to ensure that the computername is 15 characters or less, if neither conditions apply the task sequence aborts. Also you need to set your task sequence up so that it does a conditional check on the value of ALLOWOSBUILD. If the value = "No" then the task sequence will abort:

 

'==========================================================================
' NAME: ZTI-ComputerName.vbs
'
' AUTHOR: Nick Moseley
' DATE  : 6/1/2009
'
' v1.2 Edit: Christopher Nienaber
' DATE  : 4/4/2012
'
' 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
' 1.2 (4/4/2012)- Added check to ensure name is less than 16 characters, and that name
'  is not blank
'==========================================================================

Dim sNewComputerName, oTaskSequence, sTSMachineName, bPromptName, oAllowBuild
Dim bLength
Dim mBox
Set oTaskSequence = CreateObject ("Microsoft.SMS.TSEnvironment")
Set oAllowBuild = 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."
Do
 sNewComputerName = InputBox ("Enter Desired computer name to continue.", "ComputerName", , 30, 30)
 If sNewComputerName = "" Then
  bLength = False
 End If
 ' Check Length - Must not equal null and must be less than 16 characters
 If Len(sNewComputerName) <= 15 and Len(sNewComputerName) >= 1 Then
  bLength = True
 Else
  wscript.echo "Computer name must not equal null and must be less than 16 characters, prompting user to re-enter name."
  mBox = MsgBox ("ComputerName must not equal null and must be less than 16 characters, click ok to enter a new name or cancel to abort the task sequence!",1,"Invaild Computer Name")
 End IF
 If mBox = 2 Then
Exit Do
 End If
Loop While Not (bLength)
If blength = True Then
 oTaskSequence("OSDComputerName") = UCase(sNewComputerName)
 wscript.echo "Set Task Sequence variable OSDComputerName to: " & sNewComputerName
 oAllowBuild("ALLOWOSBUILD") = "YES"
 wscript.echo "A proper computer name was entered, continuing task sequence!"
Else
 oAllowBuild("ALLOWOSBUILD") = "NO"
 wscript.echo "Task Sequence aborted by user!"
End If
Else
wscript.echo "Computer Account already exists in SCCM Database, continuing Task Sequence"
oAllowBuild("ALLOWOSBUILD") = "YES"
End If

 

post-11614-0-69439000-1333640572_thumb.png

Share this post


Link to post
Share on other sites

  • 0

Hi, I've been trying to get automatic computer names working in OSD for a while with Dell machines, but not much luck, finally got it working today though so I've written a quick guide on how I got mine to work if it can help any one else...

 

Set Computer Name Automatically During OSD

Share this post


Link to post
Share on other sites

  • 0

Hello i'm new with sccm 2012, this forum saved my life several times during this few days :).

 

Now i am stuck...

 

I try to figure out a solution to automatically set the computer name during the windows 7 deployment.

 

The computer name cannot be entered manually during the deployment.it must be quiet (business requirement)

 

The workstation manufacturer has already put the computer name on a sticker at the front of the machines. (machines a delivered without OS)

 

The Computer names are linked to the machines serialnumbers in a DB. i can export it to an csv file or else.

 

I need to create the following tasks in the windows 7 deployment task sequence:

 

1: Get serialnumber (from win32_bios)

2: find the related computer name. (in a csv file or else)

3: finally apply the computer during the task sequence.

 

The problem is, I dont know if it is possible, if yes, where to begin :wacko:.

 

Thanks a lot

 

SCCM 2012 SP1 windows 2008 r2 windows 7 x64

 

 

 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...


×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.