The Configuration Manager 2007 task sequence environment variables are a set of name and value pairs that supply configuration and operating system deployment settings for computer, operating system, and user state configuration tasks on a Configuration Manager 2007 client computer. Task sequence variables provide a mechanism to configure and customize the steps in a task sequence.
When you create a task sequence in the Configuration Manager 2007 administrator console, it is stored as a sequence of steps. You can edit the task sequence steps and their associated settings in a task sequence using the Task Sequence Editor. When you run the task sequence, many of the task sequence settings are stored as environment variables. You can access or change the values of built-in task sequence variables, and you can create new task sequence variables to customize the way a task sequence runs on a target computer.
You can use task sequence variables in the task sequence environment to perform the following actions:
- Configure settings for a task sequence
- Supply command-line arguments for a task
- Evaluate a condition that determines whether
a task sequence step or group should run
- Provide values for custom scripts used in a
For example, you might have a task sequence that includes a Join Domain or Workgroup task sequence step. The task sequence might be advertised to different collections, where the collection membership is determined by domain membership. In that case, you can specify a Per-Collection task sequence variable for each collection’s domain name and then use that task sequence variable to supply the appropriate domain name in the task sequence.
Creating Task Sequence Variables
You can add new task sequence variables to customize and control steps in a task sequence. For example, you can create a task sequence variable to override a setting for a built-in task sequence step. You can also create a custom task sequence variable to use with conditions, command lines, or custom steps in the task sequence. When you create a task sequence variable, the task sequence variable and the associated value is preserved within the task sequence environment, even when the sequence restarts the target computer. The variable and its value can be used within the task sequence across different environments. For example, it can be used in a full Windows operating system and in the Windows Pre-Installation environment.
The following table describes the methods for creating a task sequence environment variable, along with usage implications for each method.
|Creation Method||Usage Overview|
Setting fields in task sequence steps using the Task Sequence Editor
Specifies set default values for the task sequence step. The variable and value are accessible only when the step runs in the task sequence. They are not part of the overall sequence environment, and they are not accessible by other task sequence steps in the task sequence.
For a list of built-in variables and their associated actions, see Operating System Deployment Task Sequence Variables.
Adding a set task sequence variable step in a task sequence
Specifies the task sequence variable and value in the task sequence environment when the task sequence step is run as part of a task sequence. All subsequent task sequence steps can access the environment variable and its value.
Defining a Per-Collection variable
Specifies a task sequence and values for a collection of computers. All task sequences targeted to the collection can access the task sequence variable and its value.
Defining a Per-Computer variable
Specifies task sequence variables and values for a particular computer. All task sequences targeted to the computer can access the task sequence variable and its value.
Adding a task sequence variable on the Variables page of the Task Sequence Media Wizard
Specifies task sequence variables and values for the task sequence that is run from the media that can access the task sequence variable and its value.
To override the default value for a built-in task sequence variable, you must define a task sequence variable with the same name as the built-in task sequence variable. For a list of built-in task sequence variables with the associated actions and usage, see Operating System Deployment Task Sequence Variables.
You can delete a task sequence variable from the task sequence environment by using the same methods as creating a task sequence variable. To delete a variable from the task sequence environment, you set the task sequence variable value to an empty string.
You can combine methods to set an environment task sequence variable to different values for the same sequence. In an advanced scenario, you might set the default values for steps in a sequence using the Task Sequence Editor and then set a custom variable value using each of the creation methods. The following list describes the rules that determine which value is used when a task sequence variable is created using more than one method:
- Set Task Sequence Variable overrides all other creation
- Per-computer variables take precedence over per-collection
variables. If you specify the same task sequence variable name for
a per-computer variable and a per-collection variable, the
per-computer variable value will be used when the target computer
runs advertised task sequence.
- Task sequences can be run from stand-alone media. Use the media
variables in place of per-collection or per-computer variables. If
the task sequence is running from stand-alone media, per-computer
and per-collection variables do not apply and will not be used.
Instead, task sequence variables defined on the Variables
page of the Task Sequence Media wizard are used to set values
specific to a task sequence running from media.
- If a task sequence variable value is not set in the overall
sequence environment, built-in actions use the default value for
the step, as set in the Task Sequence Editor.
In addition to overriding values for built-in task sequence step settings, you can also create a new environment variable for use in a task sequence step, script, command line, or condition. When you specify a name for a new task sequence variable, there are several guidelines that you must follow.
The following section describes these guidelines and provides examples of valid and invalid task sequence variable names:
- The task sequence variable name you specify
can contain letters, numbers, the underscore character (_), and a
- Task sequence variable names have a minimum
length of 1 character and a maximum length of 256 characters.
- User defined variables must begin with a
- User-defined variable names cannot begin with
the underscore character. Only read-only task sequence variables
are preceded by the underscore character.
Note Read-only task sequence variables can be read by task sequence steps in a task sequence but not set. For example, you can use a read-only task sequence variable as part of the command line for a Run Command Line task sequence action, but you cannot set a read-only variable using the Set Task Sequence Variable action.
- Task sequence variable names are not case
sensitive. For example, OSDVAR and osdvar represent the same task
- Task sequence variable names cannot begin or
end with a space or contain embedded spaces. Spaces that are left
at the beginning or the end of a task sequence variable name are
- The following table displays examples of
valid and non valid user-specified task sequence variables.
|Examples of Valid User-Specified Variable Names||Examples of Non valid User-Specified Variable Names|
The following are general limitations when creating task sequence variable:
- Task sequence variable values cannot exceed
- You cannot create or override a read-only
task sequence variable. Read-only variables are designated by names
starting with an underscore character (_). You can access the value
of read-only task sequence variables in your task sequence;
however, you cannot change their associated values.
- There is no limit to how many task sequence
variables can be created; however, the total size of the task
sequence environment cannot exceed 10 MB.
Accessing Task Sequence Environment Variables
After specifying the task sequence variable and its value using one of the methods from the previous section, you can use the environment variable value in your task sequences. You can access default values for built-in task sequence variables, specify a new value for a built-in variable, or use a custom task sequence variable in a command line or script.
The following table outlines task sequence operations that can be performed by accessing the task sequence environment variables.
|Task Sequence Operation||Usage Overview|
Configure action settings
You can specify that a task sequence step setting is provided by a variable value when the sequence runs.
To supply a task sequence step setting through a task sequence environment variable, use the Task Sequence Editor to edit the step and specify the variable name as the field value. The variable name must be enclosed in percent signs (%) to indicate it is an environment variable.
Supply command-line arguments
You can specify part or all of a custom command line by using an environment variable value.
To supply a command-line setting by using an environment variable, use the variable name as part of the Command Line field of the Run Command Line task sequence step. The variable name must be enclosed in percent signs (%).
The following command line uses a built-in environment variable to write the computer name to C:\File.txt.
Cmd /C %_SMSTSMachineName% > C:\File.txt
Evaluate a step condition
You can use built-in or custom task sequence environment variables as part of a task sequence step or group condition. The environment variable value will be evaluated prior to running the task sequence step or group on a Configuration Manager 2007 computer.
To add a condition that evaluates a variable value, select a step or group in the sequence and use the Add Condition drop down on the Options tab. Select the task sequence variable condition, and specify the variable and the value to evaluate.
Provide information for a custom script
Task Sequence variables can be read and written using the Microsoft.SMS.TSEnvironment COM object while the task sequence is running.
The following example illustrates a Visual Basic script file that queries the _SMSTSLogPath task sequence variable to get the current log location. The script also sets a custom variable.
For more information about using task sequence variables in scripts, refer to the SDK documentation.
Computer and Collection Variables
Task sequences can be configured to run on multiple computers or collections simultaneously. You can specify unique per-computer or per-collection information, such as specifying a unique operating system product key or joining all of the members of a collection to a specified domain.
You can assign task sequence variables to a single computer or a collection. When the task sequence starts to run on the target computer or collection, the values specified will be applied to the target computer or collection.
You can specify task sequence variables for a single computer or a collection. When the task sequence starts to run on the target computer or collection, the variables specified will be added to the environment and the values will be available to all task sequence steps in the task sequence.
|If the same variable name is used for both a per-collection and per-computer variable, the computer variable value takes precedence over the collection variable. Task sequence variables that are assigned to collections take precedence over task sequence variables over built-in task sequence variables.|
For more information about creating task sequence variables for a single computer or collection, please see the following topics:
- How to Create
Per-Computer Task Sequence Variables. Select
this topic for more information about specifying a task sequence
variable to a single computer.
- How to Create
Per-Collection Task Sequence Variables. Select
this topic for more information about specifying a task sequence
variable to a collection.
Task Sequence Media Variables
Task sequence variables can be specified for task sequences that are stored and run from media, such as CD/DVD sets or USB drives. You add the task sequence variables and specify their values when you create the media containing the task sequence; the variables and their values are stored on the media with the task sequence.
|When you run a task sequence from media, all custom task sequence variable information must be contained on the media; per-collection and per-computer variables cannot used with task sequences running from media.|
You can specify task sequence variables on the Variables page of the Task Sequence Media Wizard. For more information about using the Task Sequence Media, see Task Sequence Media Wizard.
Task Sequence Variables List
For a list of built-in task sequence variables, see Task Sequence Variables