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
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.
- Open the SCCM console
- Go to \Software Library\Overview\Operating Systems\Boot Images
- Right click on “Boot image (x64)” and click properties
- Click the Optional Components tab
- Click the sun icon
- Tick the box next to “Windows PowerShell (WinPE-DismCmdlets)”
- Click ok to the pop-up message
- Click ok
- Click ok
- Click yes on the “You have made changes that require you to update distribution points” pop-up
- Click next
- Click next
- 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.
To create this message pop-up message box follow these steps
- Open the SCCM console
- Go to \Software Library\Overview\Operating Systems\Task Sequences
- Open the required task sequence in edit mode
- Create a new “Run PowerShell Script” step
- Move the step to where you want it to display in the task sequence
- Give the step a Name
- Click edit script, enter the below script
1powershell.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
- Click ok
- Select “Bypass” for PowerShell execution policy
- Click ok to save the task sequence
- 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
To create this message pop-up box follow these steps
- Open the SCCM console
- Go to \Software Library\Overview\Operating Systems\Task Sequences
- Open the required task sequence in edit mode
- Create a new “Run PowerShell Script” step
- Move the step to where you want it to display in the task sequence
- Give the step a Name
- 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} - Click ok
- Select “Bypass” for PowerShell execution policy
- Click ok to save the task sequence
- Run the task sequence again and you will see the popup message
- If you press cancel you will see the below message and the task sequence will stop running
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
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
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"") |
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") |
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
- Open the SCCM console
- Go to \Software Library\Overview\Operating Systems\Task Sequences
- Edit the required task sequence
- Select the powershell script step
- Make sure that “Bypass” is selected under PowerShell execution policy