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:
- On the client, after a gather task has completed, check the OSD logs
- On the client, in a full OS, use WMIC or vbscript WMI to get the values your after
- Dump the variable values using a script, such as http://blogs.technet.com/deploymentguys/archive/2008/08/29/outputting-all-the-configuration-manager-task-sequence-variables.aspx
SCCM/MDT TS Variable Examples
Issue:
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
Issue:
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
Issue:
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=’255.255.255.255′ AND NextHop=’127.0.0.1′) 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
[Settings]
Priority=DefaultGateway,Default
Priority=DefaultGateway,Default
[DefaultGateway]
192.168.0.1=Adelaide
192.168.10.1=Melbourne
192.168.20.1=Perth
[Adelaide]
TimeZone=255
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.
link from : https://hayesjupe.wordpress.com/sccm-osd-task-sequence-variables-a-beginners-guide/
No comments:
Post a Comment