HayesJupe's Blog

SCCM OSD Task Sequence Variables – A beginners guide

Task sequence variables can be leveraged within an SCCM task sequence to perform conditional branching and execution on SCCM Task Sequence Tasks and Groups, allowing us to execute tasks only on specific computers based on something identifiable about that computer.  For example, install VPN software only on laptops or specific drivers only on their corresponding models.  This type of functionality minimises the amount of duplication of Task Sequences required and, in many cases, results in only requiring one task sequence for clients and one for servers being required.

For the purposes of this article, I’ll break Task Sequence variables down into 3 types:

  • SCCM OSD variables
  • MDT 2010 variables
  • User Defined variables


SCCM OSD variables are built in Task Sequence variables that are available in any SCCM OSD deployment – most of these are set by SCCM and need not be changed (a lot of them are also read-only) – but, its handy to know what they are – in case, one day, you do need to manipulate one in order to get your task sequence working the way you want.

A full list of these variables can be found at http://technet.microsoft.com/en-us/library/bb632442.aspx

MDT 2010 Variables are SCCM Task Sequence the variables that are by MDT’s ZTIGather process and are documented in “Toolkit Reference.doc” that comes with the MDT 2010 install. The easiest way to get the additional variables offered by MDT 2010 is to configure MDT integration for SCCM, and use the MDT Task Sequence Wizard in the SCCM console to create a task sequence based on one of the MDT template task sequences (which I recommend to use anyway)

User defined variables are passed to the Task Sequence when the Task Sequence starts execution, and can be stored either in an SCCM Resource, or an SCCM collection, and are anything you wish to define. An example of usage here would be to define a variable called “Department”, and based on its value, install software specific to that department.

How do you find out what a specific variable you want to use is?

You want to perform a task sequence step based on the model of a machine, you know the model is a HP DC7900, but, what does SCCM see it as?

There are a number of ways to achieve this goal, you can:


SCCM/MDT TS Variable Examples


You have a large number of hardware make/models and instead of using driver categories, you prefer to apply driver packages based on model.

How to obtain the model information:

From your full OS (XP/Vista/Win7) run the following command: WMIC CSProduct Get Name

From this you will get the model name as WMI sees it. Unfortunately, some hardware manufacturers decide to be, what can only be described as, absolutely fucking stupid. Some models will have

“Latitude D500”, nice and simple, a lot HP’s have “DC 7900 FRGHU89m” – we like the DC 7900 part, but the addition letters represent nothing to us and are just pain. Then we have the worst of the lot, the Lenovo’s….. where a M55e is a “9645-AM2” – naturally!

How to use this:

This is where it can get a little tricky – as there are 3 different scenarios:

1)      If you are using MDT integration and the model name is nicely formatted, you can use the task sequence variable “Model”

Example: Model equals Latitude D500

2)      If you are using MDT integration and the model name is badly formatted, the “Task Sequence variable” doesn’t support “like”, therefore, you must use WMI, instead, which does support the “like” statement and will allow us to use the wildcard “%”

Example: Select * from Win32_ComputerSystem WHERE model like “9645%”

3)      If you are not using MDT integration, you must use WMI

Example: Select * from Win32_ComputerSystem WHERE model like “9645%”

You can also leverage the “Make” of a PC in the same manner, the WMIC command line for returning the make is WMIC CSProduct Get Vendor


You want to identify laptops, so you can install laptop specific software

How to obtain the chassis information:

This one can sometimes be a little tricky. You can use WMI to detect the chassis type, or detect if there is a battery in a machine, but every now and again, some laptops will not correctly report this information.

How to use this:

1)      If you are using MDT integration, the variables “ISLaptop”, “ISDesktop” and “ISServer” are available and provide a very quick and simple method of implementing this scenario.

Example: ISLaptop equals TRUE

2)      If you’re not using MDT integration, you can use another WMI query.

Example: Select * from Win32_Battery where availability > 0



You want to the use site the build is occurring in to determine the time zone, OU, software to be installed etc

How to obtain the site information:

You should probably know which AD site or subnets relate to which to which clients – so you don’t need to really “obtain” this.

How to use this:

MDT does not provide us any cool methods using site variables in the GUI, so I’ll go through a different method a bit later, however, we can use WMI for this

Example1: Select * from Win32_NTDomain WHERE ClientSiteName LIKE ‘%Adelaide%

Example2: Select * FROM Win32_IP4RouteTable WHERE ((Mask=’′ AND NextHop=’′) AND (Destination Like ‘10.93.3%’ OR Destination Like ‘10.93.4%’)

Another option here is to customize your customsettings.ini, which will be available for those of you using MDT integration. This method is a bit more old-school, but for those of you coming from MDT backgrounds it may be more comfortable:

Example section CustomSettings.ini





MachineObjectOU=”OU=Adelaide,OU=Comps…. “

User defined Task Sequence variables examples

So you have your reference and prod task sequences all done, but you find that there are a set of applications for each department that need to be deployed – and at the moment you are assigning them post deployment, which works, but takes additional time and manual effort.

So, let’s add as variable to each SCCM resource record as we import it.

1)      Make up your CSV which contains MAC, ComputerName, Variable Value

2)      Right click on OSD | Computer association

3)      Select “import computers from a file”

4)      Select your file and assign the PC name, the MAC and the variable field… and give the variable a name

5)      Import your records

6)      In your task sequence, ad a TS Variable condition as per the entered values

So, I hope that helps someone out there with how to use TS variables…. If anyone has any issues on how to better use TS variables, by all means, post a comment and I’ll try and help with a specific example in this article.



  1. …but how do we use these variables in the task sequence?

    For example, lets say I have a variable called ‘OU’ set on a collection. I want to use this variable name in the ‘Apply Network Settings’ step of a task sequence in the ‘Domain OU’ box, so that my image will place machines into the relevant OU when they are imaged. What should I type into the box…?

    Comment by Name — April 7, 2011 @ 10:31 pm | Reply

    • Navigate to the appropriate step in your task sequence, select the “options” tab

      Add condition -> Task sequence variable
      Enter the name of the variable and the value you want it to match in order to execute the step

      Comment by hayesjupe — April 8, 2011 @ 6:35 am | Reply

      • That’s fine if I want to optionally execute a step, I understand that, but lets say I have 100+ OUs and I don’t want to create 100 ‘optional’ steps; I want to set a variable *on each collection* and use this variable in *one* task sequence step to choose which OU the put the machine.

        I’ve been searching around and the consensus seems to be to try %variable% but I’m unsure if I can just use my own variables, or if I have to set specific ones.

        Comment by Name — April 8, 2011 @ 9:21 pm

      • Cant say ive ever been in that situation – over 100 OU’s for computer objects sounds excessive.

        Anyhoo – you could use a script to modify the variable before the set OU step – but this assumes there is something in the name etc that will also identify which OU it should belong in.

        You’d really be far better off asking this type of thing at somewhere like MYITForum – its a better environment for questions that need some detail….

        Comment by hayesjupe — April 12, 2011 @ 7:00 am

  2. You only need one step in your TS. Create the Variable in each collection and call it the same e.g. DOMAINOU

    In the TS under Apply Network Settings simply reference %DOMAINOU% in the “Domain OU:” field and the TS will reference the variable from the collection your computer is in for the advertised TS.

    Comment by Dre — January 27, 2012 @ 9:14 am | Reply

    • ahhh i love that… try and make it sound like some kind of revelation!

      anyhoo – yep, your completely right – but unless you are going to have all those colelctions for some other purpose, all your doing is moving the admin from one place to another….

      Comment by hayesjupe — January 27, 2012 @ 1:39 pm | Reply

  3. […] donc fais quelques recherches et je suis tombé sur un article super intéressant « SCCM OSD Task Sequence Variables – A beginners guide » […]

    Pingback by Regrouper tous les déploiements dans une seule tâches de séquences : Peltier – Net — March 28, 2012 @ 10:31 pm | Reply

  4. […] SCCM OSD Task Sequence Variables – A beginners guide […]

    Pingback by OSD links | sccm road — October 12, 2013 @ 12:08 am | Reply

RSS feed for comments on this post. TrackBack URI

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

Blog at WordPress.com.

%d bloggers like this: