Pause a Task Sequence when you want with just a variable


In this post I will show you how to pause a Task Sequence on the fly using just a TS variable. You will be able to pause a TS when you want without to add a step in your TS, as many times as you want.

Context
You want to test something in your Task Sequence and you need to pause your Task Sequence.
You don't want to pause the TS at a specific step but to pause it when you want during the process.
You want to be able to pause your TS as many times you want.
You want for instance to be able to pause the Task Sequence using the F4 key from your keyboard (we will that in the next post)

The existing way
There are many nice posts about how to pause a Task Sequence. 
See below some of them:
SCCM Pause a Task Sequence
Pause a TS with no package
Pause a TS (Windows noob)
Pausing a TS, a bit different

In all those posts, you have to create a specific step to pause the Task Sequence, meaning you will pause it only at this specific time. 
If you want to pause it again you have to restart the deployment, add a new pause step and start again the deployment.

The new way
With this method you won't have to create a step in your TS to pause it.
You will be able to pause the TS dynamically, as many times as you want.

How it works ?
1. In order to pause the TS on the fly I modify the file ztiutility.vbs
2. I created a TS variable TSPause.
3. If the variable TSPause equals TRUE a msgbox will be displayed.
4. The msgbox will automatically pause the Task Sequence.
5. Once you click on the OK button, the variable TSPause will be set again to FALSE and the TS will continue.

How to implement it ?
1. Open the file ztiutility
2. Search the function Public Function ReportProgress. I choose this one because it's use all the time during the deployment.
3. Add the below code just below the part Dim uMaxStep
4. Update your Deployment Share

Dynamic pause in action
In the below example I proceed as below:
1. Create the TS object: 
2. Set the TSPause variable to TRUE
3. A msgbox will be displayed and pause the TS

See below the pause in action:

In the below example I added a button pause in my Task Sequence Debugger for MDT, available here.
This version will be soon available. 

In the below example I paused a TS just using a keyboard touch.

The uservoice
Three years ago I created a post about how to add the complete progression in the progress bar, as below:

I also opened a UserVoice which has bee accepted and implemented in SCCM recently, see here.
That's why I open a new uservoice, in order to add a new variable TS pause with ztiutility action to pause the TS dynamically.
Click here to vote for this idea and implement it in SCCM.

What's next ?
- Pause the TS dynamically with a keyboard shortcut
- Pause the TS from the Task Sequence Debugger