Using The Built-In Task Sequence Dialog Box

Summary

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.

This is what the finished product will look like…

Behind the scenes

In your Task Sequence…

  1. Add a new Run Command Line step
  2. 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
  3. This is what the step should look like once done.

Use-case

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

This will launch CMD as system. Run the whoami command to confirm. 

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
    $TSEnv.GetVariables()
  • Get a specific TS variable value

    $TSEnv.Value('YourVariableName')
    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.

 

Leave a Reply

Your email address will not be published. Required fields are marked *