We will be utilizing the Task Sequence COM Object to create a Dialog Box in the Task Sequence.
The purpose of this is to load the Task Sequence environment for general troubleshooting and/or having a pause in the Task Sequence. This will give you the ability to pause the Task Sequence for as long as you want – to continue, click “OK” to close the dialog box.
Behind the scenes
In your Task Sequence…
- Add a new Run Command Line step
- In the Command line: section add the following code
powershell (New-Object -ComObject Microsoft.SMS.TSProgressui).ShowMessage('Click okay when done troubleshooting', 'Pause Task Sequence', '0'); exit 0
Syntax for the ShowMessage method: [Message], [Title], [Button] – Microsoft Docs Reference
- This is what the step should look like once done.
This can be used in conjunction with the Debugging Feature in CM1910. More to come on this in the future.
Noah Swanson did a fantastic job on creating a PS Module around TSEnvironment and TSProgressUI.
One of the main reasons I use this is to check the value for the variables I set during the Task Sequence.
Once the dialog is up, we will keep it running to have the TSEnvironment loaded. Next step is to run CMD as SYSTEM. Best way to do this is to download the Sysinternals Suite and utilize PSEXEC by running the following code…
psexec.exe -i -s cmd.exe
Important: Do NOT close the dialog box. If you close it, you will no longer be able to access the TS Environment
Next type PowerShell to get into the PowerShell environment. Once we are in PowerShell (indicated by the PS on the left side of the line), we will create the $TSEnv variable with the following command…
$TSEnv = New-Object -ComObject Microsoft.SMS.TSEnvironment
Now that we have the $TSEnv variable created we can query our TS Variables.
- Return all TS Variables
Get a specific TS variable value
In my example, I’ll be returning the value for the TS Variable OSDStartInfo
Once you’re done testing, go ahead and click the “OK” button to close the Dialog Box and exit out of PSExec CMD Window.