Skip to content

Setting computername during deployment

Featured Replies

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

 

 

 

  • 2 months later...
  • Replies 38
  • Views 216k
  • Created
  • Last Reply

Top Posters In This Topic

Most Popular Posts

  • pranay bhagat
    pranay bhagat

    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 fir

  • 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

  • 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 th

Posted Images

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?

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.

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

Here is the same case that you are telling, I dont want to use the MDT integration with SCCM.

I trying for a solution only with SCCM.

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?

 

  • 3 weeks later...

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

  • 3 months later...

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

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

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

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.