Tuesday, March 15, 2011

Generate Computer names in MDT 2010/SCCM based on prefix and a sequence number including OU assignment

I must admit MDT and SCCM works nice together, but it lacks some features like auto generating names(sequentially) and dynamically assigns clients to OU based on multiple criteria’s (at least what I know…)
What I’ve been struggling with the last days are to auto generate names to unknown computers being installed with a new Win7 image. I came across http://www.deployvista.com/Home/tabid/36/EntryID/120/language/en-US/Default.aspx
Which solved my naming issue… Good work Johan Arwidmark:)

But I still had one issue left; the OU structure is more complex than just location or type. I need to put the computers in an OU structure based on location and type of client.
The OU structure is like this; OU=ComputerType,OU=Computers,OU=Location, DC=domain,DC=local.
To resolve this issue, I’ve expanded the stored procedure Johan created, and created an extra table to store the following info:
  • Location – The name of you Location example: New York
  • Gateway IP – The same as MDT. What Gateway identifies the New York location
  • Shortname – The shortname of location for use in computername example: NY
  • BaseOU – the OU string for this location: OU=Computers,OU=New York,OU=Locations,DC=domain,DC=local
To populate the information you want to use for generation, you have to use SQL Management Studio to add information to the table.

In addition you need to change the MachineObjectOU column in the MDT settings table to more than 50 characters. I used 255 since I know my OU paths aren’t longer than that. But in my case 50 characters are too short.

Based on the information above the stored procedure will create a computer name sequentially in the following format PCLOCATIONSEQUENCE, example PCNY00001. The computer account will also be created in the OU=Laptop,+BaseOU or OU=Desktop,+BaseOU or OU=VM,+BaseOU based on the %islaptop%, %isdesktop% or %isvm% parameters in MDT.

To change the naming convention for the computer name, edit the stored procedure to change the order or add hyphens (-) for segmentation.

In the MDT/SCCM task sequence you need to use the %OSDDomainOUName% and not the %machineobjectOU%

I’m not a SQL guy, so the code might be a mess, but it’s working. I’ll try to rewrite the procedure to optimize the code. But I don’t know when it will be finished.

Download files here:

Run the scripts on you MDT database and add the following configure to your current Customsettings.ini:

Priority=IdentifyComputer, CSettings

Parameters=UUID, AssetTag, SerialNumber, MacAddress

Parameters=MacAddress, DefaultGateway,Islaptop,IsDesktop,IsVM

1 comment:

Naz said...


I am trying to so something similar but our computer names are generated using a mixture of

1. task sequence selected for this computer
2. PC model
3. suffix is just a 4 digit number entered by the engineer.

here is an email I send to someone to assist me but I have had nothing back.

I have recently had SCCM 2007 deployed and I have produced my master task sequence

I wish to automate 2 parts of the computer naming process of an unknown computer in the task sequence and needed your assistance as to how I would approach this.

Here is some background


When I PXE boot a new PC (unknown to SCCM)
•I enter the administrator password
•I am then presented with the option to select which task sequence I wish to deploy (there are about 10, 1 for each department)
•The first 2 parts of the computer name should be then be generated based on the task sequence I select and part of a WMI query that takes park of the hardware model number.

The third part is where I am stuck, our PC names are created using 3 fields DepartmentID-PCModel-ASSETTag

This is what I what I would like to do for the task sequence to do (I presume this will be a mixture of VBScript, SQL query and a HTA front end for the last part where I enter the asset TAG number)

1.The first part of the computer name should be populated based on the task sequence selected eg. If I select the Merchandising Task sequence then the first part of the computer name should populate to MER-
2.The second part of the computer name should populate using a WMI query that gets the model number so for example for a HP Elite 8200 CM, the query should pick up 8200 and then the 2nd part of the computer name should be populate – so we have IT-8200
3.Once the 1st 2 parts of the computer name have been generated, they it should be displayed in the HTA front end allowing me to finish the last part of the computer name detailed in step 4.
4. Now the 3rd part is the asset tag – this is just a sticker that we stick on the PC which helps identify it. This can just be entered by the administrator imaging the PC. So once the user enters the 4 digits of the ASSET tag we would have IT-8200-xxxx

Reason I wish to do it like this is that it minimises user error and typo’s in the computer name.

Do you think this is achievable and could you possibly help creating the script/query/HTA front end to generate the full computer name.

At the moment this is what happens with my SCCM task sequence

1. I PXE boot a new machine
2. I enter the admin password to connect to the network share
3. I select the appropriate departmental task sequence
4. I am then asked to enter the full computer name for the OSDCOMPUTERNAME task sequence variable