Jump to content


anyweb

Setting computername during deployment

Recommended Posts

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


did you Add a "Set Task Sequence Variable" to the postinstall phase before the "Apply Windows Settings" step ?

 

 

see the following screenshot, however in this screenshot i'm making the computername=the Asset Tag of the computer

 

all you have to do is to leave the assettag value empty

 

osdcomputername.jpg

Share this post


Link to post
Share on other sites

did you Add a "Set Task Sequence Variable" to the postinstall phase before the "Apply Windows Settings" step ?

 

 

see the following screenshot, however in this screenshot i'm making the computername=the Asset Tag of the computer

 

all you have to do is to leave the assettag value empty

 

post-1-12644489834875_thumb.jpg

 

 

I assume %AssetTag% is being set by Gather?

 

Thanks,

 

Mike

Share this post


Link to post
Share on other sites

Gather gathers info, see below from the Print Ready Documentation, so it will Gather a value for %AssetTag% from the computers bios, next the task sequence above, that value is assigned in the Set Task sequence variable step, and then this is then used by the Configure command (listed below) or during the Setup Windows and ConfigMgr step

 

if you bring up a command prompt (F8) and browse the c:\windows\panther\unattend\unattend.xml file you can see it gets changed during these steps to the values you selected

 

Gather

This task sequence step gathers data and processing rules for the target computer.

 

Configure

This task sequence step configures the Unattend.xml, Sysprep.inf, or Unattend.txt files with the required property values that are applicable to the operating system you are deploying to the target computer. Following is a brief listing of the settings that show how this step was originally configured in one of the MDT 2010 task sequence templates. For more information about which script accomplishes this task and which properties you use, see ZTIConfigure.wsf.

Share this post


Link to post
Share on other sites

if you want to rename the computer without using MDT try the suggestion here

 

join a workgroup at the Apply Network Settings step, I have a Run Command Line using the wsname.exe command to change the name after the Setup Windows and ConfigMgr step and then a Join Domain or Workgroup step after that to join it to the domain.

Share this post


Link to post
Share on other sites

This method probably would be okay if we had SCCM DHCP server which we do not. I am using task sequence created boot disc only to build the computer with a captured image. We are not advertising the task to any collection.

Share this post


Link to post
Share on other sites

here's a quick TIP

 

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 ?

 

oh and here's another way from the very talented Michael in Denmark :)

 

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
objItem.SerialNumber=env("OSDComputername")

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...

 

 

Great post, this has been helpful!!

 

I want to find out if anyone has had any success with creating a custom Task Sequence that renames a computer??

 

For instance, I'm working on a TS that will prompt for a new name, unjoin the machine from the domain to a workgroup, then rejoin with a new name.

 

Thus far I am able to prompt for and obtain the new name either when the TS is launched from PXE by using a TS Variable, or when launched from the Run Advertised Programs control panel applet by using a script to prompt for the name.

 

The point I am at a stall at is when it comes to applying the new name. From what I know the only time the variable for OSDComputerName is paid attention to is during the "Applying Windows Settings" task. However, since this isn't a full OSD TS there seems to be an issue with using this step in my custom TS. There is a Task Sequence error that references this, it's small but I won't paste it in this entry however, I will attach the error to this posting as a text file if anyone is curious.

 

 

This thread has been active on and off so I hope there are still members out there paying attention who might have some ideas on how to get around this or on another method to use. Thanks in advance!

 

 

UPDATE:

My Apologies, everyone. I thought I scanned through this entire article but it appears I did not!

There is a posting by AnyWeb on Feb 23rd that provides an option to perform just what I'm trying to do by using a third party name changing tool.

 

These forums are extremely helpful. Thanks again!

TaskSequenceError.txt

Share this post


Link to post
Share on other sites

So I get the prompt during the build phase and I type in a name. But it never applies. I set the task sequence variable in the task sequnce as defined on this string and left it blank but nothing ever happens. Using SCCM 2007 R2

Share this post


Link to post
Share on other sites

I have the exact same problem, the computername that I input during the early stage of the task sequence never gets applied to the computer. After I created an mdt boot image I also get prompted for the computername before selecting the task sequence to run but it never gets applied, the computer is always named minint....

 

Why is it that the computer is never renamed according to the name I input?

Share this post


Link to post
Share on other sites

Revrat and Orto

 

Only create a Variable on the SCCM collection with a NULL value and do not create a Task Sequence variable for OSDComputername.

 

By default the TS will check the collection variables and if Null prompt you.

 

I had the same problem and its working great now that I removed the TS variable.

 

Hope this helps

 

PS. We using SCCM R3 with NO MDT

Share this post


Link to post
Share on other sites

hi all,

I am using serial number script with MDT 2010 task sequence...i added the script and the variable to the post install phase of the task sequence....but the new deployed machine is not able to get the serial number...

I tested the script with SCCM 2007 and there was no issue.

where to put the script in the mdt task sequence?????

 

thanks ,

pranay.

Share this post


Link to post
Share on other sites

just as an update...

 

the script is working fine with MDT 2010...after few changes i figured out that we need to put the script and declare a task sequence variable as OSDCOMPUTERNAME after the first initializing phase of the task sequence....

  • Like 1

Share this post


Link to post
Share on other sites

here's a quick TIP

 

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 ?

 

 

Pardon the hijacking...

 

Will this also work with SCCM 2012 Beta 2?

 

I tried the steps above, but I was never prompted for the computer name. I added the "Set Task Sequence Variable" right after "Apply Operating System"

 

Thanks.

Share this post


Link to post
Share on other sites

just as an update...

 

the script is working fine with MDT 2010...after few changes i figured out that we need to put the script and declare a task sequence variable as OSDCOMPUTERNAME after the first initializing phase of the task sequence....

 

You even don't need the script. You can just run the 'gather' from MDT and then set the variable with %SerialNumber%. The gather will deliver some useful information about your system for finetuning your task sequence. For example applying drivers to several systems you can use the model variable which is read from the BIOS during gather. It's also telling you if the system is a laptop, desktop or virtual pc.

Share this post


Link to post
Share on other sites

Hello Everyone, I have been following and using the guides on here to set up an SCCM lab for OSD, (which are amazing, thanks so much Niall for providing this information) I have tested different deployment methods and I am looking at using the unknown computer support, I was able to incorporate one of the scripts to be prompted to specify a computer name, which works great by the way, but I would like to take this step a bit further and have a menu driven selection to create the computer name from the selections made, ie first three digits would be select your location, next would be your business unit and then is it an XP or Win7 machine, is a it a laptop or desktop and then pull in the last 4 or 5 digits from the serial number to generate a unique name. Anyone have any experience or suggestions for something like this?

Share this post


Link to post
Share on other sites

I don't know if this would be helpful, but I wrote a powershell script that sets the machine name based on the subnet the computer is sitting on during the imaging process. We have distinct sites and subnets, so this works well. Basically, based on subnet, the first three characters will be the site code (LAV for Las Vegas, NYC for New York City, etc.); the fourth and fifth characters are WW for Windows Workstation; the sixth character will be D for Desktop, N for Notebook or W for Workstation (based on a WMI query); the final seven characters will be the asset tag set in the BIOS (also based on a WMI query). I can post if someone would be interested.

  • Like 1

Share this post


Link to post
Share on other sites

is there a way to customize the computer name using the task sequence. I want the names to be OS-Location-001 etc..

 

Example: Win7-Adm-001, Win7-Adm-002 and so on...

 

Thanks

Chuck

Share this post


Link to post
Share on other sites

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

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

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

Join the conversation

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

Guest
Reply to this topic...

×   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...