Using Windows 10 Toast Notifications with ConfigMgr Application Deployments

When deploying software with ConfigMgr, the ConfigMgr client can create a simple “New software is available” notification to inform the user that something new is available to install from the Software Center. But this notification is not overly descriptive. You might wish to provide a more detailed notification with a description of the software, why the user should install it, the installation deadline etc. For Windows 10, we can do that simply by disabling the inbuilt notifications on the deployment and creating our own custom toast notifications instead.

The Notification

Consider the examples below.

Here I have created a simple toast notification with the name of the software, what it does, what it is needed for, and a simple instruction to close Outlook before installing. The user can then choose to install it now – and clicking on that button will simply open the Software Center to that application via it’s sharing link. If they click Another time… the notification goes away for now, and if they dismiss it, it will move to the Action Center.

Title Only

In this version, I’ve added a logo instead of a title…

Image Only

…and in this version, I’ve added both.

Title and Image

If the deployment has a deadline, you can state the deadline in the notification as well as tell the user how long they have left before the deadline is reached.

Image with Deadline

Clicking Install now opens that app in the Software Center where the user can go ahead and install it…

Software Center

The big gotcha (for now) is that this only works with Application deployments, and you need to be running ConfigMgr 1706 or later. Please, Microsoft, make sharing links possible for other deployments (packages/programs, task sequences) too!

The client machines also need to be running Windows 10 Anniversary Update or later for the notification to work properly.

The Magic

So how does this work? Well, first we need to disable the inbuilt notifications on the application deployment, so set that to Display in Software Center, and only show notifications for computer restarts in the deployment type on the User Experience tab.

Next, we create a compliance item and compliance baseline which will display the notification. Target the compliance baseline at the same collection/s you are targetting your application.

The compliance item will have a PowerShell discovery script and remediation script. The discovery script will simply detect whether the software has been installed and report compliance if it is. The remediation script contains the code that displays the notification, and will only run if the discovery script does not report compliance, ie the software is not yet installed.

The Code

For the discovery script, create some code that will detect whether the software is installed. For my example, I used the code below which simply checks for the existence of a registry key.


## Discovery script for Veritas Enterprise Vault Outlook Add-in (x64) 12.2.1.1485

$RegKey = "HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\{0DBA46D1-5D49-4888-BC50-D3DF38F85126}"
If (Test-Path $RegKey)
{
    "Compliant"
}
Else
{
    "Not compliant"
}

It’s important that the script outputs a value whether it’s compliant or not, so you don’t get issues with the instance not being found.

For the remediation script, I created the following code to display a toast notification:

Code Walkthrough

Let’s walk through the code to explain the variables and what it does.

Variables

Title is the notification title that displays more prominently, the name of the software for example.

SoftwareCenterShortcut is the sharing link from your ConfigMgr application. To get this, you simply deploy the application to a machine, go to the Software Center, open the application and in the top-right click the link and copy and paste the link as the variable value.

AudioSource is the sound that displays when the notification appears. There are various options here, see the reference in the script for more info.

SubtitleText and BodyText contain the main wording in the notification.

HeaderFormat is a choice of either:

  1. TitleOnly – this just displays a title in the notification header
  2. ImageOnly – this just displays an image in the notification header
  3. TitleAndImage – this displays both

Base64Image – if you wish to include an image or a logo, use this optional variable. You need to convert an image file to a base64 string first, and code is included in the script for how to do that. You can output the base64 string to a text file and copy and paste it back into the script in this variable.

The reason for encoding the image is simply to avoid any dependencies on files in network locations, setting directory access or requiring internet access. The script will convert the base64 string back to an image file and save it in the user’s temporary directory.

Deadline is an optional parameter. If your deployment has a deadline, you probably want to include that in the notification. Deadline should be a parseable datetime format.

What the Script Does

The script will register PowerShell in the HKCU registry as an application that can display notifications in the Action Center, if it isn’t registered already.

Next it defines the toast notification in XML format. I chose XML to avoid any dependencies on external modules, and it’s actually quite simple to create a notification that way. The schema for toast notification is all documented by Microsoft and you can find a reference in the script.

Next it manipulates the XML a bit depending on whether you chose to display an image or use a deadline etc.

Finally, the notification is displayed.

Duration

The notification uses the reminder scenario so that it stays visible on the screen until the user takes action with it. If this is undesirable, you can change it to a normal notification with either the standard or longer duration. In this case, you need to be sure that the text in the notification can be read in that time frame.

In the toast template XML definition, change the first line from:

<toast scenario=”reminder”>

to either (default duration 5 seconds)

<toast duration=”short”>

or (around 25 seconds)

<toast duration=”long”>

Creating the Compliance Item and Baseline

When creating the compliance item in SCCM, make sure of the following:

  • Supported platforms – should be Windows 10 only. Actually, I have used some features in toast notifications that are only available in the Anniversary Update and later, so don’t target versions less than.
  • User context – make sure the compliance item has the option Run scripts by using the logged on user credentials checked
  • Compliance rule value – the value returned by the script should equal “Compliant
  • Compliance rule remediation – make sure that Run the specified remediation script when this setting is noncompliant is checked

When creating the deployment for the compliance baseline in SCCM, make sure of the following:

  • Remediate noncompliant rules when supported is checked
  • Allow remediation outside the maintenance window is checked (if that is acceptable in your environment)

Conclusion

This is a handy way to create your own notifications for ConfigMgr application deployments in Windows 10 and is fully customizable per application, within the limits of the toast notification schema. If and when Microsoft make sharing links available for task sequences, or packages and programs too, this would become even more useful, for example, sending a custom notification when a Windows 10 version upgrade is available.

Advertisements

12 thoughts on “Using Windows 10 Toast Notifications with ConfigMgr Application Deployments

  1. As you mentioned in duration section, I don’t see short and long is not working when i perform dismiss or another time. I don’t see notification again when i use Short and Lond Tags.

  2. Hi trevor

    Great script, works well! Is there a way to trigger the application from the xml for the toast instead of just using the shortcut ID to open up the app in software center?

    Thanks

  3. I figured out a way to make this work with Updates as well. You have to change the $SoftwareCenterShortcut to the below which pulls up the update in the “Updates” section in Software Center like the original pulls up the app in the “Application” portion.

    $SoftwarecenterShortcut= “softwarecenter:SoftwareID=Site_8E25450A-4C7E-4508-B501-B3F0E2C91541/SUM_99d11a78-2df9-48e9-985e-11968f50fbcd”

    So “ScopeID” needs to be changed to “Site” and the value (at least in my case) stayed the same. In then the second half of it “Application” changes to “SUM” and you can find both of these values in the “UpdatesDeployment.log” but the update itself is not enumerated to a friendly name for the update. To find that go into the “WUAHandler.log” and then look for the friendly name of the update.

    Example of finding the “SUM”:
    Update (Missing): Feature update to Windows 10 (business editions), version 1803, en-us (99d11a78-2df9-48e9-985e-11968f50fbcd, 201)

    So the whole of the first portion should look like this for the 1803 update:
    # Required parameters
    $Title = “Windows 10 Version 1803”
    $SoftwarecenterShortcut= “softwarecenter:SoftwareID=Site_8E25450A-4C7E-4508-B501-B3F0E2C91541/SUM_99d11a78-2df9-48e9-985e-11968f50fbcd”
    $AudioSource = “ms-winsoundevent:Notification.Default”
    $SubtitleText = “A new build of Windows 10 is now required in Software Center.”
    $BodyText = “This update will require a reboot. Please have your computer plugged into AC power before running”
    $HeaderFormat = “ImageAndTitle” # Choose from “TitleOnly”, “ImageOnly” or “ImageAndTitle”

  4. Great work Trevor!

    Just as a side note for anyone else, when converting image to base64, .ico throws an exception. Go for a proper png\jpg :).

    Rich Mawdsley

  5. This looks awesome. I’m able to see the code from the reply section, but not from the main wordpress page. Odd… anyway, I am having a hard time getting the Header Format section to display both text and an image. It works fine if you do just text, or just an image, but if you do both, it only displays whichever one is listed first. Thoughts? I couldn’t find a good online resource that shows both together like you’ve got here. Any help would be appreciated!

  6. Hi guys, I’ve tried to add some customization to be able to snooze the deploy using below code and I’ve noticed that reminder appears to be a couple or more minutes off, or reappear right away.
    One more thing, when I dismiss the notification it still pops up sometimes. What is controlling this? If the app is install how does the notification gets disabled?
    Also, found that compliance baseline doesn’t trigger the notifications in time (even if I have few hours for policy to run or run them manually) unless I’m running it manually from Configuration Manager –> Configurations Tab in Control Panel.
    Have you had any similar issues? Your advice will be really appreciated.

  7. We update W10 by task sequence. Gives a possibility to find the SoftwareID for the task sequences and to generate a link from it ?

    1. Last time I checked you can’t shortcut to a Task sequence, only to Applications – a major limitation in this scenario. A workaround which I have tested is an Application that calls the Task sequence, but that’s a bit ‘hacky’ and does mean you end up with both a task sequence and an Application to deploy W10 and could be confusing to the users.

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