How can I display custom messages in a task sequence using PowerShell in System Center Configuration Manager (Current Branch)

Introduction

At the start of this series of step by step guides you installed System Center Configuration Manager (Current Branch), then you configured discovery methods. Next you configured boundaries to get an understanding of how automatic site assignment and content location works. After that you learned how to update ConfigMgr with new features and fixes using a new ability called Updates and Servicing and you learned how to configure ConfigMgr to use Updates and Servicing in one of these two modes:

To prepare your environment  for Windows 10 servicing (this guide) you learned how to setup Software Updates using an automated method (via a PowerShell script) or manually using the ConfigMgr console. Next you used a PowerShell script to prepare some device collections, then you configured client settings for your enterprise and finally you’ll deployed the ConfigMgr client agent using the software updates method which is the least intensive method of deploying the Configuration Manager client agent.

 

As System Center Configuration Manager (current branch) is being delivered as a service now, version 1602 was made available (March 11th, 2016) and you used Updates and Servicing to do an in-place upgrade to that version as explained here. Next you learned about how to use the Upgrade task sequence to upgrade your Windows 7, Windows 8 (and 8.1) and even your Windows 10 devices to a later build of Windows 10.

 

You then learned about the new Windows 10 servicing features which use Servicing Plans in ConfigMgr (Current Branch). Next you integrated MDT 2013 update 2. MDT integration with ConfigMgr is useful as it provides additional functionality for operating system deployment scenarios such as Offline Language Package installation or User Driven Integration (UDI).

 

Next you learned how to deploy Language Packs offline for Windows 10. To assist with Windows 10 servicing and for applying appropriate software updates to your Windows 10 devices, you used PowerShell to add queries to the various Windows 10 collections.

 

Next you took a deeper look at the Windows 10 Upgrade task sequence, and learned one way of dealing with potential upgrade issues. While that method will flag a problem, such as determining the system UI language doesn’t match the provided media, it won’t allow you to continue with the upgrade. Next you learned how to upgrade the operating system when a language pack was installed, provided that the system UI language is from a ‘list’ of approved languages that you intend to support.

 

This guide will show you how to display customized messages to a user during a task sequence, and how to set an exit code which could allow you to deliberately fail an action if necessary. All that’s required is a few steps to set variables, a PowerShell script, and the serviceUI.exe executable from MDT 2013 Update 2.

 

Step 1. Create a package

On your ConfigMgr server, in the sources share, create a folder called Display Custom Message and place the DisplayCustomMessage.ps1 PowerShell script available in the downloads section of this guide, in the folder. Even though you might be deploying an X64 operating system, locate, select and copy the x86 architecture version of ServiceUI.exe from the Sources\OSD\MDT\MDT2013u2\Toolkit\Tools\x86 folder

 

serviceui.png

 

into the Display Custom Message folder as shown below.

 

display custom message.png

 

In the ConfigMgr console, Software Library, select Packages and right click, choose Create Package. Fill in the following details,

 

create package.png

 

Choose Do not create a program and then continue through the wizard until completion.

 

package created.png

 

Once the package is created, right click the package and choose Distribute Content.

 

distribute content.png

 

Distribute the package to your distribution points.

 

distributed.png

 

 

Step 2. Create a custom task sequence

In the ConfigMgr console, in Software Library, select Operating Systems and right click on Task Sequences, choose Create Task Sequence.

 

Create Task Sequence.png

 

select Create a new custom task sequence

 

create a new custom task sequence.png

 

give the task sequence a suitable name such as Display Custom Messages with exit codes

 

create task sequence wizard.png

 

continue through that wizard until completion.

 

custom ts done.png

 

Step 3. Edit the task sequence

Right click on the newly created task sequence and choose edit

 

edit task sequence.png

 

It will appear blank, click on the Add Drop down and add a New Group called Display Custom Message

 

Create a new Set Task Sequence Variable step called Set Title with a Task Sequence Variable called Title, with a suitable value as follows:

 

set title.png

 

Create a new Set Task Sequence Variable step called Set Message with a Task Sequence Variable called Message, with a suitable value as follows:

 

set message.png

 

Create a new Set Task Sequence Variable step called Set ReturnCode with a Task Sequence Variable called ReturnCode, with a suitable positive value as follows:

 

set returncode.png

 

Click Add and choose Run Command Line, name the step Display Custom Message and paste in the following:

ServiceUI.exe -process:TSProgressUI.exe %windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe -WindowStyle Hidden -NoProfile -ExecutionPolicy bypass -nologo -file DisplayCustomMessage.ps1

For Package, select the Display Custom Message package created above.

 

display custom message step.png

 

Copy the entire group and paste it below the first group

 

copy paste.png

 

Edit the Set Message step as below

 

set message to fail.png

 

Edit the Set ReturnCode step, and choose a value that the Options tab on the Display Custom Message step is not going to expect such as 1, this will cause the next step to fail when it returns the return code.

 

returncode 1.png

 

Apply your changes and exit the Task Sequence wizard.

 

ready to apply.png

 

Step 4. Deploy the task sequence

Right Click on the task sequence and choose Deploy

 

deploy task sequence.png

 

Choose a suitable collection and use a purpose of Available.

 

deployed.png

 

Step 5. Review the capabilities

On a client computer that is in the collection that the task sequence was deployed to, open Software Center and select the Display Custom Message with exit codes task sequence.

 

display custom message in software center.png

 

choose Install

 

install.png

 

and after a few moments the first popup message appears !

 

custom message.png

 

As the ReturnCode for the first message was set to a value we expected (0 or 3010) it did not fail the task sequence. Click OK to continue…

 

the next message appears, note the different text, and it’s hinting towards what will happen

 

custom message 2.png

 

Clicking OK will produce the failure

 

task sequence failed.png

 

Which is OK because we were expecting it, in fact, the ReturnCode we set (1) is listed in the failure message. In a real Production task sequence however, you’d take care of failures and deal with them in a professional way, I just want you to see that we can actually set the ReturnCode via the custom message.

 

To get more proof of that refer to the SMSTS.log file, and you can see that it’s setting the ReturnCode to the value we chose

 

exit code 1.png

 

result !

 

Summary

Popping up messages to users during a task sequence is sometimes necessary, and when things go wrong, you sometimes need to fail the task sequence or set a ReturnCode to do a planned action. This guide helps you do both of those things dynamically.

 

Related Reading

Downloads

You can download a Microsoft Word copy of this guide here dated 2016/05/26

Attached File  How can I display custom messages to users during a task sequence in SCCM Current Branch.zip   1.91MB   7 downloads

 

You can download the PowerShell script used above here.

 

Attached File  DisplayCustomMessage.zip   592bytes   8 downloads

This entry was posted in 1602, PowerShell, System Center Configuration Manager (Current Branch). Bookmark the permalink.

5 Responses to How can I display custom messages in a task sequence using PowerShell in System Center Configuration Manager (Current Branch)

  1. amar_r says:

    I get an unknown error in the SMSTSlog. When I run the ServiceUI command manually I get the following error “Process Not Found: [TsProgressUI.exe]”

  2. santoshk says:

    I don’t think the above msg pop up will work with SCCM In-Place Upgrade task sequence. is there anything which can run in during In-Place Upgrade?

  3. livingod101 says:

    I been banging my head against the table for the past 3 days and finally figured out why following this did not work. I am using MDT 8456 default boot image from SCCM 2012 build 8913. The reason the pop-up did not work is the location of Powershell has shift from what’s written above “%windir%\sysnative\WindowsPowerShell\v1.0\powershell.exe” to new location “%windir%\system32\WindowsPowerShell\v1.0\powershell.exe”

  4. Pingback: Все, что необходимо знать об SCCM — Links for IT folks

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.