How To Display Custom Pop-up Message Box In SCCM Task Sequence

Jason Barrett Jason Barrett | | Task Sequence

Below I will show you how to display a custom pop-up message box which can be run in a SCCM task sequence.

Personally in all of my task sequences I put a message that says “Warning Your Hard Drive will be wiped if you continue

Below I will show you how to display the following message types

  • Simple Message Pop-up Box : Continue when OK pressed
  • Message Pop-up Box With Cancel : Continue when OK pressed, Exit if Cancel pressed
  • Message Pop-up Box With Cancel & Timeout : Exit task sequence if cancel is pressed, Continue if OK selected or timeout reached

Below is an example of a simple message pop up box

Custom Pop Up Message Box

How To Display Custom Pop Up Message Box

In all of the methods I am going to show you to create a custom pop-up message box require the PowerShell extension adding to the boot image.

1. How To Add PowerShell Extension To Boot Image

To add the PowerShell extension to the boot image follow these steps.

  1. Open the SCCM console
  2. Go to \Software Library\Overview\Operating Systems\Boot Images
  3. Right click on “Boot image (x64)” and click properties
    boot image properties
  4. Click the Optional Components tab
  5. Click the sun icon
    boot image optional components
  6. Tick the box next to “Windows PowerShell (WinPE-DismCmdlets)”
  7. Click ok to the pop-up message
  8. Click ok
    select optional components
  9. Click ok
  10. Click yes on the “You have made changes that require you to update distribution points” pop-up
    changes require you to update distribution points
  11. Click next
  12. Click next
  13. Click close

We can now use PowerShell commands in our task sequences.  We will use PowerShell to create the pop-up messages.

2. Creating A Simple Message Pop-up Box

By using powershell we can utilize the SMS.TsProgressUI to create a simple pop-up message box that will display during a task sequence.

The task sequence will then pause until the OK button has been pressed.  The pop-up message we are going to create here will look like the one below.

Custom Pop Up Message Box

To create this message pop-up message box follow these steps

  1. Open the SCCM console
  2. Go to \Software Library\Overview\Operating Systems\Task Sequences
  3. Open the required task sequence in edit mode
    open task sequence edit mode
  4. Create a new “Run PowerShell Script” step
  5. Move the step to where you want it to display in the task sequence
  6. Give the step a Name
  7. Click edit script, enter the below script
    1
    powershell.exe -command (new-object -ComObject Microsoft.SMS.TsProgressUI).CloseProgressDialog() ; (new-object -ComObject wscript.shell).Popup('Warning: Hard Drive 0 will be wiped. ',0,'Warning',0x0 + 0x30) ; Exit 0
  8. Click ok
  9. Select “Bypass” for PowerShell execution policy
    add sccm task powershell step
  10. Click ok to save the task sequence
  11. Now the above message will pop-up when the task sequence is started as it is the first step

3. Creating A Message Pop-up Box With Cancel

The next message pop-up box I will show you will have a message pop-up with an OK button which can be pressed to continue the task sequence and a cancel button which will error the task sequence if pressed.

The message will look like below

message popup with cancel

To create this message pop-up box follow these steps

  1. Open the SCCM console
  2. Go to \Software Library\Overview\Operating Systems\Task Sequences
  3. Open the required task sequence in edit mode
    open task sequence edit mode
  4. Create a new “Run PowerShell Script” step
  5. Move the step to where you want it to display in the task sequence
  6. Give the step a Name
  7. Click edit script, enter the below script
    1
    2
    3
    4
    $wshell = New-Object -ComObject Wscript.Shell
    $answer = $wshell.Popup("Warning: Running this task sequence will ""WIPE YOUR HARD-DRIVE"", Press OK to continue or CANCEL to cancel the deployment",0,"Confirm To Continue
    Notification"
    ,1 + 4096)
    if($answer -eq 2){Exit 1}
  8. Click ok
  9. Select “Bypass” for PowerShell execution policy
    add sccm task powershell step
  10. Click ok to save the task sequence
  11. Run the task sequence again and you will see the popup message
  12. If you press cancel you will see the below message and the task sequence will stop running
    message popup with cancel error screen

4. Creating A Message Pop-up Box With Cancel & Timeout

With the previous message pop-up we created the task sequence will wait for you to click ok or cancel before it continues.

In this section we are going to configure a timeout so the task sequence will continue if no option has been selected for a certain amount of time.

The message will look the same as before but I added a line to notify you have 60 seconds to enter an option.  The message will look like

Message Pop-up Box With Cancel Timeout

To configure this message follow the previous steps to create a powershell step in the task sequence and enter the below code

1
2
3
4
$wshell = New-Object -ComObject Wscript.Shell
$answer = $wshell.Popup("Warning: Running this task sequence will ""WIPE YOUR HARD-DRIVE"", `n`nPress OK to continue `nPress CANCEL to cancel deployment`n`nYou Have 60 Seconds To Decide",60,"Confirm To Continue
Notification"
,1 + 4096)
if($answer -eq 2){Exit 1} else {Exit 0}

Replace the two 60 numbers with the amount of seconds you wish to set.

Formatting The Message Pop-up Text

Here I will take you through all the options you have to format the text in the message that pops up.

How To Replace Text In Body

To Replace the text in the body replace “Text In Body Here” with what you want

1
2
$wshell = New-Object -ComObject Wscript.Shell
$answer = $wshell.Popup("Text In Body Here")

Replace with

1
2
$wshell = New-Object -ComObject Wscript.Shell
$answer = $wshell.Popup("Warning: Running this task sequence will WIPE YOUR HARD-DRIVE, Press OK to continue or CANCEL to cancel the deployment")

Will look like this

simple message popup text

How To Replace Text In Header

To replace the text in the header we need to add the code “,0,”Running Task Sequence””

1
2
$wshell = New-Object -ComObject Wscript.Shell
$answer = $wshell.Popup("Warning: Running this task sequence will WIPE YOUR HARD-DRIVE, Press OK to continue or CANCEL to cancel the deployment,0,"Running Task Sequence"")

edit message header

How To Add Line Breaks

To add line breaks to make the text a bit easier to read we need to add `n

1
2
$wshell = New-Object -ComObject Wscript.Shell
$answer = $wshell.Popup("Warning: Running this task sequence will WIPE YOUR HARD-DRIVE`n`nPress OK to continue`nPress CANCEL to cancel the deployment",0,"Running Task Sequence")

edit message with line breaks

Frequently Asked Questions

Listed below are the frequently asked questions

Why Is The Message Not Popping Up

If the powershell execution policy is not set to bypass the message will not pop-up when the task sequence is run.  To resolve this follow these steps

  1. Open the SCCM console
  2. Go to \Software Library\Overview\Operating Systems\Task Sequences
  3. Edit the required task sequence
  4. Select the powershell script step
  5. Make sure that “Bypass” is selected under PowerShell execution policy
    message not showing

Leave a Comment