Task Sequence Powershell Module

Awhile ago I submitted a request to Microsoft for a built-in Powershell Module during the Task Sequence. Mostly for basic things like getting and setting variables, but once I noticed what all the COM Objects exposed, I wanted to take this a step further.

Primarily you’ll have 2 COM objects you can create during a Task Sequence: Microsoft.SMS.TSEnvironment (getting/setting variables) and Microsoft.SMS.TSProgressUI (manipulating the Progress and messages). I’ve uploaded the module for you all to use at my github. I’ll run though some of the details below including visuals for the TSProgressUI items. Some, if not most, of these are-for lack of a more appropriate label-useless; but can still be fun to mess around with!




This function is not exported, as it is used within the module to verify that the Microsoft.SMS.TSEnvironment COM Object is loaded before attempting any operations.


Calls “GetVariables()” on the COM Object. This will return an array of all Task Sequence Variable NAMES only.


Calls “Value()” on the COM Object to return the value of a specific variable. the “Name” Parameter should be the Task Sequence Variable you want the value for.


Assigns a value to a specific variable. A Boolean return indicates success. Note this is wrapped in a try/catch in the event you attempt to set a read-only variable.


Returns an object of all Task Sequence Variables and their assigned Values.



This function is not exported, as it is used within the module to verify that the Microsoft.SMS.TSProgressUI COM Object is loaded before attempting any operations.


Calls “ShowActionProgress()” on the COM object. This is the function I use 99.9% of the time for UI related actions. This will add the “second” progress bar and update the Text for that progress bar as well as fill the progress meter as you see fit. The neat thing here, is that the “Step” and “MaxStep” will automatically show a “100%” representation. For example, if i have 8 of 400 complete, I don’t have to do the extra scripting to pass in “2” and “100”. I can pass in 8, and 400, and the COM Object does the math for us.

There are other parameters here with “ShowActionProgress()”. With this function, those use the built-in variables “designed” to be used here. If you want to extend this function to allow those additional parameters, feel free. Personally, I don’t find them useful enough to include.

Step Param set to 5, MaxStep Param set to 10.


Calls “CloseProgressDialog()” on the COM object. Closes or “hides” the progress bar window. This will automatically reappear once the current step has completed, or if you call one of the “show” functions for the UI.


Calls “ShowTSProgress” on the COM object. This function manipulates the “Top part” of the progress bar. If, for whatever reason, you wanted to manipulate the progress bar without adding the “second/bottom” bar, this is what you should use.

Step Param set to 5, MaxStep Param set to 10.


Calls “ShowErrorDialog()” on the COM object. This wills how the typical “Error in the Task Sequence” Window. There are parameters for the error title, error message/details, exit code, a timeout, and a force reboot. The force reboot will trigger a reboot after the timeout (in seconds) has expired.



Calls “ShowMessage()” on the COM Object. This essentially shows a MessageBox allowing you to specify the button configuration. The interesting (and somewhat useless) part of this, is that you do not receive a return value. If you want a simple “OK” message box, this should work, otherwise I’d recommend using a Normal MessageBox.

Button Options (Type Parameter):

  • 0 = OK
  • 1 = OK, Cancel
  • 2 = Abort, Retry, Ignore
  • 3 = Yes, No, Cancel
  • 4 = Yes, No
  • 5 = Retry, Cancel
  • 6 = Cancel, Try Again, Continue

Type Param set to 0.


Calls “ShowRebootDialog()” on the COM Object. This will allow you to present a custom reboot window. I would recommend against this, as untimely reboots during a task sequence can cause some issues. This is essentially what causes the issue where Updates cause Double Reboots during OSD. If you do need a reboot after a step, either inset a restart computer step in your task sequence or just have your script exit “3010”.

Typically OrganzationName will use the TS Variable “_SMSTSOrgName”.


Calls “ShowSwapMediaDialog()” on the COM Object. If you’ve ever used standalone media that was broken up into multiple CD/DVD sets (or played a Final Fantasy on Playstation), you’ve seen this one. This is a message indicating for you to swap media, letting you know what disk number to insert.




9 thoughts on “Task Sequence Powershell Module

  1. Nice module 🙂
    One question. Is there a way to update both the “first” and “second” progress bars ? I have a PowerShell script that carries out a number of steps and I want to show the progress of each step in the “second” progress bar and also update the overall progress in the “first” progress bar.
    Doco bug .. “get-help show-tsprogress -examples” has examples for Show-TSActionProgress rather than Show-TSProgress

    • Thanks 🙂

      There’s not a single call you can make to update both progress bars. Typically the top progress bar is hard-set to the Current Running Action of the Task Sequence. The second progress bar is there for you to freely update to indicate the progress of your custom action. I can’t recall off the top of my head but I’m pretty sure the top TS bar will update to the hard-set actions when the second is updated. Now, in theory if that didn’t, I suppose you could call Show-TSProgress and then Show-TSActionProgress… My recommendation is to do one of two things:

      1. Break apart your action to where each “action” is it’s own step in the Task Sequence, this would update the top bar as you want allowing the bottom to show that custom progress.
      2. Simply make the bottom bar “Message” a bit more verbose.

      We’ve got some heavy scripts that run and we’ve done things where the second bar will say “Running action 1/3: Setup File System” as the message and then do progress as normal…next part “Running action 2/3: Set File Permissions” and restart the progress bar back to ‘0’. Really there’s no “wrong” way to do it but that’s my recommendation.

  2. Hi,
    I hope this is still being monitored? We have recently upgraded to 1806 and since that upgrade, our powershell menu option to install specific packs no doesn’t seem to show, whereas before, it did. I can attach the script if need be.

  3. Hi, basically it’s a task sequence we have which asked for a computer name (which works, but is a vbscript), and 2 PS scripts which ask for what language and font they want to install. I can’t see any errors. It looks like its goes through the steps for the PS scripts, but doesn’t show the menu? I just seems to ‘pause’ for anout 5 seconds, then move on? The script is below as it doesn’t show any info:
    # Close SCCM GUI Elements
    $TSProgressUI = New-Object -COMObject Microsoft.SMS.TSProgressUI

    # XAML Code
    [xml]$XAML = @’


    #Read XAML
    $reader=(New-Object System.Xml.XmlNodeReader $xaml)
    try{$Form=[Windows.Markup.XamlReader]::Load( $reader )}
    catch{Write-Host “Unable to load Windows.Markup.XamlReader.”; exit}

    # Store Form Objects In PowerShell
    $xaml.SelectNodes(“//*[@Name]”) | %{Set-Variable -Name ($_.Name) -Value $Form.FindName($_.Name)}

    # Set Standard TS Variable language to English
    $tsenv = New-Object -COMObject Microsoft.SMS.TSEnvironment
    $tsenv.Value(“language”) = “English”

    # Add events to Form Objects
    [string]$selection = $comboBox.SelectedItem
    $language = $selection.Substring(37)

    Write-Host $language

    $tsenv.Value(“language”) = $language


    # Show the form
    $Form.ShowDialog() #| out-null


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s