Windows 10 Toast Notification Script

Description

The Windows 10 Toast Notification Script enables you to create nice and nifty toast notifications for the logged on user in Windows 10. This can be done with Configuration Manager or with Group Policy Preferences and Scheduled Tasks (and probably other means too).

This is an extended version of the script and scenario described in my last WaaS post: https://www.imab.dk/windows-as-a-service-remind-users-of-pending-windows-upgrades-using-windows-toast-notifications/. For inspiration, I suggest you have a peek at this too 🙂

The script comes with 2 main purposes/features:

  • UpgradeOS
  • PendingRebootCheck

UpgradeOS is meant to be used with Windows Servicing, notifying users about new available Windows versions. This is primarily intended to be used with ConfigMgr. The main idea here is to lure the end-user into a voluntary participation and make them initiate the in-place upgrade themselves.

The toast notification displayed for the end-user in such scenario, may look similar to below left example, where the Install button will redirect the user into the Software Center:

PendingRebootCheck is the second purpose/feature and is displayed above to the right. The idea here is to increase compliance and overall stability of the running computers by reminding users of pending reboots. A reboot is also considered pending, if the uptime of the computer exceeds x amount of days. Other pending reboots are checked through WMI and registry. No actions are currently attached to the toast in this scenario.

Configuration

The entire toast notification is configurable through the config-toast.xml. The idea here is, that the purpose of the toast notification can be modified without the need to push new files and/or update distribution points in ConfigMgr. There are bits and pieces which cannot be changed from the config-toast.xml and in that case you will have to modify the actual Powershell script.

I have included 2 configuration samples in the download; one for use with Windows Servicing and another for checking for pending reboot.

Images

The images are changeable. Just replace ToastHeroImage.jpg and ToastLogoImage.jpg with your own. Some of the images I’m using throughout my posts is paid pictures and protected by copyright.

Logging

ConfigMgr admins loves logging! The script logs all its actions to ProgramData\ToastNotificationScript\New-ToastNotification.log. This is useful when troubleshooting or if curious of what is done. Also, there are some combinations in the config-toast.xml which doesn’t makes sense and thus these are prevented. The log will tell when that happens.

Documentation

I have included a first draft of the documentation in the download.

Download

https://gallery.technet.microsoft.com/Windows-10-Toast-9f228eb1

15 thoughts on “Windows 10 Toast Notification Script”

  1. Hi,

    that is a great feature, but how often check the script the uptime and show the message?
    And where can i configute the interwall?

    Best regards
    Robert

  2. Hi,
    in your previous version the scandinavian alphabets (å ä and ö) were working OK.
    In this version they render wrong.
    Could this be fixed?

    Thanks for your great work!

    • Hey, great input. I actually never tested that even though I’m from Denmark myself. Let me look into that and get back to you 🙂 I assume it’s due to the text is now set externally in the xml.

  3. What could cause the error for displaying the Notification?

    2019-03-14 11:34:10 INFO: No HeroImage file set as parameter. Using local image file
    2019-03-14 11:34:10 INFO: No LogoImage file set as parameter. Using local image file
    2019-03-14 11:34:10 INFO: Successfully loaded \\sccm04-vm\sources$\Packages\Software\ToastNotificationScript\config-toast-rebootpending.xml
    2019-03-14 11:34:10 INFO: Loading xml content from \\sccm04-vm\sources$\Packages\Software\ToastNotificationScript\config-toast-rebootpending.xml into variables
    2019-03-14 11:34:10 INFO: Successfully loaded xml content from \\sccm04-vm\sources$\Packages\Software\ToastNotificationScript\config-toast-rebootpending.xml
    2019-03-14 11:34:10 INFO: PendingRebootCheck set to True. Checking for pending reboots
    2019-03-14 11:34:10 INFO: Running Test-PendingRebootRegistry function
    2019-03-14 11:34:10 INFO: Check returned FALSE on ANY of the registry checks: Reboot is not pending!
    2019-03-14 11:34:10 INFO: Running Test-PendingRebootWMI function
    2019-03-14 11:34:10 INFO: Computer has SCCM client installed – checking for pending reboots in WMI
    2019-03-14 11:34:10 INFO: Check returned false on checking WMI for pending reboot: Reboot is not pending!
    2019-03-14 11:34:10 INFO: Creating the xml for displaying both action button and dismiss button
    2019-03-14 11:34:10 INFO: Toast notification is used in regards to pending reboot. Uptime count is greater than -3
    2019-03-14 11:34:11 INFO: All good. Displaying the toast notification
    2019-03-14 11:34:11 INFO: Something went wrong when displaying the toast notification

    • Are you running the toast as another user than the user logged on? 🙂 The toast only runs in the context of the user being logged on as it obviously needs to be interactive and display to the user. If you are running this with SCCM, you need to make sure your program runs in the users context 🙂

  4. Hi again.
    Can you explain the MaxUptimeDays Value? What means the value “-3”?
    And
    Can you fix the script for German language (äöüß)?

    Thanks

    • That was just me testing, going back in time. My computer was just restarted when I did that part, so I had to go back in time with a negative value. MaxUptimeDays is the maximum days a device is allowed to not have rebooted and thus displays the toast.

    • I’m afraid that’s not possible. A limitation in the API itself and is limited due to protecting the OS 🙂

  5. Would it be possible to start a OS upgrade task sequence directly instead of opening the software center application only?

    • You have the option to use softwarecenter:Page=OSD to open Software Center directly into the OS page. Not exactly what you are desiring, but close. 🙂

Leave a Comment

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