If you have worked with SCCM/ConfigMgr Task Sequences for any length of time, you’ve likely needed to debug them. Many times, you need to check the value of a Task Sequence variable. The generally accepted approach is to add a Run Command Line step to your Task Sequence and run ServiceUI.exe like this:
ServiceUI.exe -process:TSProgressUI.exe cmd.exe
This approach is great if you planned ahead and you are in a test Task Sequence. It will pause the Task Sequence until you close the command prompt which allows you time to do any testing you need to do and even write scripts and test them live within your Task Sequence. It is a really handy tool to use. But what if you are trying to debug a production Task Sequence and can’t add the debug step?
I was trying to track down an issue with my Task Sequence where a variable wasn’t being set, but I didn’t want to add the debug step. The Task Sequence was still in WinPE so I opened a command prompt using F8. Then I launched powershell. From there, I ran the following 2 commands to get the value of my OSDComputerName variable.
The first line creates the TSEnvironment object which has access to all of the variables inside the Task Sequence. The second gave me the value of the OSDComputerName variable. You can change this to any valid variable name. If you don’t know what variables are currently loaded, you can run this command to get a list:
This works great in WinPE as long as the Task Sequence is running. In some cases, adding the debug step is a better way to go if you need to pause at a specific point, but if you are just looking quickly check a value, this is a great way to do it. If you want to do this while in Windows, you need to be running as Local System. To do that, I use SysInternals Tools and run:
psexec.exe -i -s powershell.exe
The -i opens the session interactively. The -s runas as Local System. Powershell.exe can be replaced by whatever process you want to launch in the system context. Once there, you can launch the same commands as above as long as the Task Sequence is running.
This is just another tool to have in your SCCM/ConfigMgr toolkit. Hope it helps you someday.