Task Sequences are used heavily in Operating System Deployment (#OSD), but they are also used to control the workflow of installing applications, migrations, updates and even patching. Just like any piece of work in the IT world, we need to go through a Dev, QA, Prod lifecycle while developing these. More often than not, even the simplest Task Sequence needs a little debugging. Perhaps in your own Task Sequence you’ve developed, or perhaps you inherited the Task Sequence.
During the development of your task sequence you may want to stop it before it gets to a certain point. This will allow you to check the current system or components (File system, registry, DB values) to see if they’re using the expected configuration. Maybe the next step is to apply the Operating System image, or upgrade an application. During these steps, or even after, it may be too late to check the system configuration.
Run a command line program and error Codes! Pretty simple if you think about it. Let’s take a look.
Inside the Task Sequence, do the following:
- Add a Run Command Line task
- Set the name to: DEBUG – Force Task Sequence to Fail
- In the command line type: cmd /c exit 1
- Click Apply
How it Works
This simple, yet elegant command allows you to tell the Task Sequence that it has encountered an error. To be precise, Errorlevel 1.
Let’s open up the Options tab for the DEBUG – Force Task Sequence to Fail
By default, the Run Command Line tasks looks for Successful exit codes of 0 and 3010 (Requires a reboot). Because our command line is returning 1, which does not match 0 or 3010, it means that we have encountered an error! That’s what we want!
If you’re having trouble tracking down where a problem exists, you could copy and paste this command into a few locations in the task sequence and change the error value for example to cmd /c exit 123.
Do you have any other reasons why you might want to have a task sequence fail? Post them below in the comments section!