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

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

 

Hi - I think you would maybe need to use Orchestrator to do something like this?

Share this post


Link to post
Share on other sites

  • 0

I am also facing the same issue.



I am using SCCM 2012.



The requirement for me is same, I am trying to assign the computername to the Workstations with respect to Serial number.


and for example the name should appear as "ABC00000000", some text+serial number.



I wrote the VBscript, this gets the serial number and adds the number to the text and then assigns the computer name to the workstation.


The script is working like a Champ when I am testing manually.


But I am missing the order to keep the script in the Task-Sequence.



Please help me to get the sequence where to place exactly.



I dont have the script with me right now to post it. I will post the script ASAP.



Thanks All.

Share this post


Link to post
Share on other sites

  • 0
On 4/17/2013 at 10:46 PM, Veerla said:

 

I am also facing the same issue.

 

I am using SCCM 2012.

 

The requirement for me is same, I am trying to assign the computername to the Workstations with respect to Serial number.

and for example the name should appear as "ABC00000000", some text+serial number.

 

I wrote the VBscript, this gets the serial number and adds the number to the text and then assigns the computer name to the workstation.

The script is working like a Champ when I am testing manually.

But I am missing the order to keep the script in the Task-Sequence.

 

Please help me to get the sequence where to place exactly.

 

I dont have the script with me right now to post it. I will post the script ASAP.

 

Thanks All.

 

This process will do exactly what you are trying to do (I use this process every single day without any problems) and tells you where to put it in your task sequence - however, it does use MDT so if you do not have this integrated this will not help:

 

Set Company Name Automatically During OSD

Share this post


Link to post
Share on other sites

  • 0

Dim strSN

'************************************************************************************************************************************************
Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colBattery = objWMIService.ExecQuery("SELECT * FROM Win32_Battery")
'************************************************************************************************************************************************

Set objNetwork = CreateObject("WScript.Network")
strComputer = objNetwork.ComputerName
Set objWMIService = GetObject("winmgmts:" & "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

'************************************************************************************************************************************************
'Part 1 – Acquire serial/service tag number
Set colSMBIOS = objWMIService.ExecQuery ("Select * from Win32_SystemEnclosure")
For Each objSMBIOS in colSMBIOS
strSN = objSMBIOS.SerialNumber

' Is this a Desktop or a Laptop
If colBattery.Count = 1 Then
' Is a Laptop
strSN = "LPT" & strSN
Else
' Is a Desktop
strSN = "DSK" & strSN
End If

If strSN <> "" Then exit For
Next
'************************************************************************************************************************************************

Set objWMIService = GetObject ("winmgmts:" & "!\\" & strComputer & "\root\cimv2")
Set colAdapters = objWMIService.ExecQuery ("Select * from Win32_NetworkAdapterConfiguration Where IPEnabled = True")


Set objComputer = GetObject("winmgmts:{impersonationLevel=Impersonate}!\\" & _
strComputer & "\root\cimv2:Win32_ComputerSystem.Name='" & _
strComputer & "'")

strComputer = "."
Set objWMIService = GetObject("winmgmts:" _
& "{impersonationLevel=impersonate}!\\" & strComputer & "\root\cimv2")

Set colComputers = objWMIService.ExecQuery _
("Select * from Win32_ComputerSystem")


For Each objComputer in colComputers

ErrCode = objComputer.Rename(strSN)

Next

 

 

I got this scenario worked 90%, but I am getting a small error when i am using the above script.

the script is not giving me the battery information in the logic I am using...

if I am running the script manually on the OS it is working fine. but when I am doing OSD it is not working :(

can someone please help me if I am missing something?

 

Share this post


Link to post
Share on other sites

  • 0

I haven't done much with testing for a laptop in a task sequence, so you'll want to test this, but one idea might be to change your chunk of code that says:

' Is this a Desktop or a Laptop
If colBattery.Count = 1 Then
' Is a Laptop
strSN = "LPT" & strSN
Else
' Is a Desktop
strSN = "DSK" & strSN
End If

 

 

With this chunk of code and see if it works as expected:
strSN = "DSK" & strSN
For Each objItem in colBattery
strSN = "LPT" & strSN
Next

 

For what it's worth, I always use "Option Explicit" to make sure I declare all my variables in a script...

Share this post


Link to post
Share on other sites

  • 0

Hey Guys,

 

firstly, I love this site, without it setting up SCCM 2012 & deploying images to tablets would of taken a lot longer.

 

Anyway I would like to use a script to automatically assign a computer name to the tablet in its deploy TS

 

I need the computer name to start with the static name "tablet" followed by the last 5 digits of the serial number i.e tabletxxxxx

 

Scripting wouldn't be my strong side so any help would be greatly appreciated.

 

James

Share this post


Link to post
Share on other sites

  • 0

I got this working if anyone is interested:

 

Dim objWMIService
Dim colItems
Dim colBattery
Dim objSMSEnv
Dim strNewName
Const strSite = "Tablet"

 

Set objWMIService = GetObject("winmgmts:\\.\root\CIMV2")
Set colItems = objWMIService.ExecQuery("SELECT * FROM Win32_Bios")
Set colBattery = objWMIService.ExecQuery("SELECT * FROM Win32_Battery")

' Get the Serial Number
For Each objItem In colItems
' Remove all beginning, trailing and containing spaces and change to all upper case
strNewName = UCase(Trim(Replace(objItem.SerialNumber, " ", "")))
Next

strNewName = Right(strNewName, 5)

'Site Code + Last 5 of Serial Number
strNewName = strSite & strNewName

' Set the Environment Variable that controls the Computer Name
Set objSMSEnv = CreateObject("Microsoft.SMS.TSEnvironment")
objSMSEnv("OSDCOMPUTERNAME") = strNewName

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.