MDT 2010: Automating Computernames using Task Sequence Conditions

I’ve updated this post on 1 April 2012 as the screenshots shows the gather as being the first step when in fact the gather has to run after the computername has been set so that it can collect the data. Sorry for that readers.

I’ve come across this issue a few times now so it’s time to post it as a blog. The scenario is that your company wants to automate computer name generation using serial numbers and indicators that show the machine type and location. The end result is that computer names are automatically created during deployments like in these examples:

Birmingham Server computername: B-S-12345
Edinburgh Virtual Machine computername: E-V-12345
Manchester Laptop computername: M-L-12345
London Desktop computername: L-D-12345

One solution to this is to use task sequence conditions in combination with the read only MDT variables DefaultGateway, IsVM, IsLaptop, IsDesktop and IsServer.

First, create a folder as a container for the various choices and call it Set Computername. Next, create more folders in a tree structure listing each of your site locations. Birmingham, Edinburgh, London and Manchester in my examples.

Click on the first site(Birmingham), then on the Options tab, select add If Statement.

Select Any Conditions and click OK.

Next, add a task sequence variable.

Enter the variable DefaultGateway and use the equals operator and the value of the first sites routers IP address (Default Gateway). in my example.

Repeat this step for any other default gateways on the site. The result should look like this:

Do the same for the remaining sites. This will now detect the site based on the default gateways above.

Next, it’s time to create the optional computer name steps. First, highlight the first site and select General then click Set Task Sequence Variable.

This folder is Birmingham and we want it to target a laptop so under name type Computername Laptop then enter the variable OSDComputername with the value B-L-%SerialNumber%.

Do the same for Desktop, Server and Virtual Machine following the same logic.

Finally, create task sequence conditions for each step as in the examples below:

Computername for Laptop This tells MDT to only process this step if the computer is a Laptop.
Computername for Desktop This tells MDT to only process this step if the computer is a Desktop.
Computername for Server This tells MDT to only process this step if the computer is a Server.
Computername for Virtual Machine This tells MDT to only process this step if the computer is a Virtual Machine.

This process can be repeated for the remaining sites in the organisation. The result is that the computer names are now generated automatically.

About Andrew Barnes

A Scripting and Deployment Specialist.
This entry was posted in Deployment, MDT 2010 and tagged , . Bookmark the permalink.

7 Responses to MDT 2010: Automating Computernames using Task Sequence Conditions

  1. archee says:

    Good post, thanks.


  2. Pingback: SCCM & MDT 2010 Naming of Computers within Task sequence using OSDComputerName Variable « Sccmmonster's Blog

  3. Thiago says:

    NIce work!
    I’m a noob at deployments. but
    Does this add the computer into the MDT database??

    Our organisation has a naming convention of eg SHQLT01


  4. Tarkan Koemuercue says:

    Very good post to configure the settings on “one” task.
    Another way to solve that for all Task sequences:
    just have a look at the deploymentguys script to solve that as an userexit script, which will run on each of your task sequence. This will be initialized on each deploymentpoint during the ts initialization of gathering the information from the customsettings.ini file.


  5. Tarkan Koemuercue says:

    not really. You need to confgure a database access first. This can be done within the customsettings.ini file or using powershell!


  6. Paul says:

    I am having a small problem and getting this to work. I have set up the locations and rules like the post says but I am not getting computers the location name is seems that the computername is being missied. Do I need to put a gather command to get to this to work?


    • Yes, The gather shoould run after the computernames section. I’ll update the screenshots.
      Please note, this is only for complex computernames. For simple computernames based on site location, use the MDT database.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s