Task sequences are the core driver for any OSD
operation. They consist of a series of customizable tasks or
sequentially performed steps. ConfigMgr 2007 advertises task sequences
to a collection in a similar fashion to software distribution packages.
Many task types are built into ConfigMgr, and the Microsoft Deployment
Toolkit adds a handful of useful tasks as well. Additionally, you can
create your own tasks using the SDK if you cannot find one that fits
your needs.
The New Task Sequence Wizard, available from the
context menu of the Task Sequences node, quickly builds one of two
default task sequence types or a custom task sequence:
Build and Capture
Deploy an Image
These two task sequence types take care of a
majority of the scenarios in OSD; however, task sequences are flexible
and not limited to what is produced by default. The task sequence editor
allows easy customization of the task sequences; you can tailor
sequences to the specific OSD needs of an organization—and with a little
imagination, software deployment.
The wizard also presents the option to build a
custom task sequence; task sequences built using the custom option are
initially blank. Figure 1 shows the first screen of the New Task Sequence Wizard.
To edit a task sequence, right-click it and choose Edit; choosing
Properties from the context-menu results in the Properties dialog box of
the task sequence and not the task sequence editor. Adding a task is
simply a matter of choosing the Add drop-down menu, choosing a task
category, and then selecting the task. Each task is customizable and has
its own configurable parameters.
1. Variables
Tasks and task sequences are similar to a
macro-based programming language or a storyboard where you put together
high-level steps and instructions using a graphical tool, without having
to know or learn the syntax of the underlying language to take
advantage of it fully. Additionally, third parties can add, and have
added, tasks extending this pseudo-macro language enhancing what you can
do with task sequences.
A major advantage that task sequences have over
the traditional software delivery mechanism used in Systems Management
Server and now ConfigMgr is that they maintain a state between steps.
This state is embodied in a series of built-in variables and custom
variables that survive reboots, allowing you to pass data or
configuration items from one step to the next. In fact, the task that
the task sequence is currently executing is also part of the task
sequence’s state. Variables are encrypted for security when transmitted
between ConfigMgr and the target system.
Here are the three types of variables available:
Action— Specify parameters for specific tasks. Nearly all are directly editable using the task sequence editor.
Custom— Simple name and value pairs that you can define as you see fit.
Built-in—
Mostly read-only, start with an underscore, are generated automatically
by the task sequence, and generally describe the environment where the
task sequence executes.
The full list of task sequence action and built-in variables is available at http://technet.microsoft.com/en-us/library/bb632442.aspx. Action variables and custom variables can be set in a number of ways:
Using a Set Task Sequence Variable task.
Statically assigning them to a specific computer resource.
Statically assigning them to a collection.
Using the Microsoft.SMS.TSEnvironment COM object in a script or other COM compliant language.
Leaving
the value of a collection or computer variable blank (new with
ConfigMgr 2007 R2). The built-in task sequence UI prompts the user for
values for these empty variables.
Task sequence variables set by a Set Task
Variable task take precedence over computer-specific variables, which in
turn take precedence over collection variables. Collection variables
propagate down the site hierarchy with other collection settings. You
can assign computer variables only at the site the computer is a member
of, and they do not propagate up or down a site hierarchy.
You can use variables for the following tasks:
Conditionally execute tasks.
Perform string replacement in command lines. (See the example later in this section and Figure 2.)
Provide task-specific parameter values. (See the example in this section and Figure 3.)
Perform string replacement in unattended files.
For string replacement and parameter values, surround the name of the variable with % symbols; for example for a variable named MyCustomVar, use %MyCustomVar%. The task sequence engine replaces this with the value of the variable. As an example, Figure 19.15
shows the Run Command Line task. This figure demonstrates adding an
entry to the Registry that you can later utilize to track the deployment
version used when creating the system. You can supply the actual
version by a collection variable or a preceding Set Task Sequence
Variable task.
Figure 3
shows an example of replacing a parameter in a task. This example shows
how you can use multiple product keys in a deployment. You can supply
the actual product key in a collection variable or a preceding Set Task
Sequence Variable task.