Windows 7 / Getting Started

Task Conditions and Grouping

You can apply conditions to the execution of any task allowing execution only when certain conditions exist or statements evaluate to true-for example, if the hardware model of the system is a Dell E6510. This makes task sequences flexible and allows you to build complex, multipurpose task sequences. Add conditions to a task by going to the Properties tab of a task and using the Add Condition drop-down button.

Each condition evaluates to either true or false; if all listed conditions evaluate to true, the task executes normally. The task is skipped if any condition evaluates to false.

Conditions can be combined using If statements forming a master conditional statement. Master statements are a collection of substatements; they evaluate to either true or false based upon the logical evaluation of their substatements. There are three types of master statements; each type of evaluation affects how the master statement is evaluated:

  • All child statements must be true.
  • Any child statement is true.
  • No child statements are true.

You can chain If statements to form complex logical statements. If statements in this context closely resemble the traditional logical operators "and" and "or", and can be used in a similar way.

Conditions can be built based on the value of a task sequence variable, the OS version, a file's version or timestamp, a folder's timestamp, a value from the registry, a WMI Query, or installed software. One thing to be aware of is that conditions are evaluated at the point they are defined in the task sequence. What this means is that if you want to perform a task based on the state of the current OS after the initial reboot of the system into WinPE, you must set a conditional variable before the reboot and use that conditional variable to execute the desired task conditionally.

For example, perform the following steps to install Microsoft XML Notepad during a refresh scenario, using a task that executes only if the software was installed previously on the system:

  1. Create a Set Task Variable task before the Restart in WinPE task. This is important to place before the first Restart in WinPE task so that it runs in the currently installed OS. This task is effectively a no-op in a replace or new computer scenario.
  2. Set a variable, such as InstallXMLNotepad, to True.
  3. Go to the Options tab of this task and add an Install Software condition; locate and select the installation MSI for the product when prompted, XMLNotepad.msi in this case.
  4. Highlight the Install XML Notepad task in the task tree on the left to edit it; select the Options tab for this task and add a new task sequence variable condition. Set this condition to check the value of InstallXMLNotepad equal to True.

You can collect tasks into a hierarchy of groups. This allows tasks to be aesthetically organized, and also gives the flexibility of conditionally executing tasks in a group and discontinuing the execution of a group of tasks if one fails, without affecting the entire task sequence. You can add separate execution conditions to each group in the exact same way that you add them to an individual task. ConfigMgr evaluates each task for its completion state; checking whether it completed successfully, and performs the following actions for an unsuccessful task:

  • If a task does not complete successfully, the group containing the task is also set to unsuccessful, and ConfigMgr discontinues processing tasks in the group.
  • If the task is not contained in a parent group, then the task sequence itself is set to unsuccessful and terminated.

You can override the default behavior using the Continue on Error option available on the Options tab of each task and group. If the Continue on Error option is set, ConfigMgr ignores the error state of the task or group and processing continues sequentially as if no error occurred. You can find an excellent example of grouping tasks together to control the flow of a task sequence and handling errors at http://blogs.msdn.com/steverac/ archive/2008/07/15/capturing-logs-during-failed-task-sequence-execution.aspx.

[Previous] [Contents] [Next]