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 3 main purposes/features:

  • UpgradeOS
  • PendingRebootCheck
  • PendingRebootUptime

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. Pending reboot here is checked in the registry and WMI.

PendingRebootUptime is the third purpose/feature. In this scenario, the uptime of the computer is considered. When the uptime exceeds the value defined in the config.xml, the toast is displayed reminding users to restart more often.

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 log files! 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.

Version history

  • 1.0 – Script created
  • 1.1 – Separated checks for pending reboot in registry/WMI from OS uptime.
  • 1.1 – More checks for conflicting options in config.xml.
  • 1.1 – The content of the config.xml is now imported with UTF-8 encoding enabling danish, german etc. characters to be used in the text boxes.
  • 1.2 – Added option for personal greeting using given name retreived from Active Directory. If no AD available, the script will use a placeholder.
  • 1.2 – Added ToastReboot protocol example, enabling the toast to carry out a potential reboot.
  • 1.3 – All text elements in the toast notification is now customizeable through the config.xml
    • Expanded the options for finding given name. Now also looking in WMI if no local AD is available.
    • Added Get-WindowsVersion function: Testing for supported Windows version
    • Added Test-WindowsPushNotificationsEnabled function: Testing for OS toast blockers
    • Added some more detailed logging
    • Added contributions fromย @SuneThomsenDKย @ย https://www.osdsune.com
      • Date formatting in deadline group
      • Fixed a few script errors
      • More text options

Download

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

86 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

    • I’m afraid this is Windows 10 only ๐Ÿ™ It’s based on an API which is only available in Windows 10.

  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. ๐Ÿ™‚

  6. First off all thanks for the solution

    Fix ร†ร˜ร…:
    To support other ร†ร˜ร… change line 168 – Think it work with german char to but havent testet
    $Xml = [xml](Get-Content -Path $Config)
    to this
    $Xml = [xml](Get-Content -Path $Config -Encoding UTF8)

    We needed something like this for our environment but we still stuck with Windows 7 so i created a “form” to serve that side too.

    Windows 7 Reboot Notification Form
    Posted i here https://gallery.technet.microsoft.com/Windows-7-Reboot-23a8377d

    Longquo/DK

  7. Thank you for this great feature!

    Is it possible to use the Toast Notifications for normal Windows Updates?
    Would be amazing, users could defer the updates for some time.

    • Hey, I attach two images in the download. Take a look at the the sizes of those and you have a good idea. ๐Ÿ™‚

  8. Hello, I am trying to use toast notification to prompt users to install software from Software Center. I would like to give users the option to click on a button to go to a website to get more information about the software that is required to install. I have been able to create the new button but struggling to get the website to open either through Internet Explorer or Edge. Do you know if this can be done and if so, how can I accomplish this?

    • There’s nothing built into the script which would do the translation. All of the text comes from the config.xml for you to customize yourself ๐Ÿ™‚

  9. Thanks for the scandinavian alphabet support. Working just nicely!

    One question, can the image (heroimage, the bigger one) size vertically be altered anyway if the horizontal size stays the same.
    I mean so that the toast wont stretch it automatically to 180 pixels vertically if the image is something like 340×100.

  10. Hi Martin,

    Nice work, however, I was attempting to show others this script, however, I attempted to run on Windows 10 1809 (OS Build 17763.379). It seemed to process, but did not display the notification. Thoughts?

    • Hey, what does the log file in programdata\toastnotificationscript say? How are you running the script? Manually? How’s your execution policy configured? ๐Ÿ™‚

  11. False alarm. Was just me testing the “TargetOS” option in the XML. LOL. ;-). It works and will not show the toast notification if the running OS and target OS are the same.

  12. Hey Martin
    First: Thank you for that great idea and all the provided work!

    I`m now wondering if it is possible to start a powershell script when hitting the “install” button.

    • Hello Ralf, I’m afraid that’s not possible due to restrictions in the OS. It’s prevented due to security reasons ๐Ÿ™‚

  13. Hey, thanks for a very cool solution.

    Just a headsup for other users, if you are not using SCCM, make sure to change config file to use PowershellApp instead of SoftwareCenterApp, or else you are not seeing any notifications ๐Ÿ™‚ SoftwareCenterApp is not a default Windows 10 app, but comes as part of SCCM.

  14. Hello, first off thanks for your work and sharing this. I believe I have it almost up and running but I’m running into a slight problem. I only get a pop up saying “New Notification” using either PowerShell or SCCM. We do have SCCM installed so would prefer to go that route. I’m not seeing the pop up of the images above do you know where I’m going wrong? Thanks.

    • Hey, does it work when run out-of-the box directly after download without doing any changes to images and the config? Does the log say anything useful? (programdata\toastnotificationscript\new-toastnotification.log)

        • Hey Nathan, there must be some sort of configuration in your OS preventing toast notifications. There are few which can do that. I’m very curious to know the ups and downs. I’m planning to add some sort of check for blockers, those that I know of making it more clear what’s going on.

          • I am experiencing the same issue, I am still only at the stage of testing the script by running it manually.

            I have run the script using Powershell and Software Center Toast, and have tried running it OOTB on both Windows 10 1703 and Windows 10 1903.

  15. Hi Martin, Thank you!!! it is very helpful ?

    is it possible to assign tag and group for toast notifications via PowerShell? And is it possible to clear the notifications from ActionCenter conditionally using tag and group?

      • Hi Martin,

        We want to show toast message to inform the users to reboot the Windows 10 machine.

        Scenario:
        1. Toast message is shown to the user requesting to reboot the machine.
        2. User is moving the toast message to Action Center.
        3. After some time, user is rebooting the machine.

        But, the toast message exists in Action Center. I want to remove the toast message conditionally from Action Center , when user login again. To my knowledge, this can be achieved by assigning tag to the toast message. Later toast message can be removed from Action Center using PowerShell by referring the tag, but I do not know the PowerShell code to use.

        Thanks,
        Thangaselvam

    • Hey, if you have the Snooze button enabled, that will always include both action button AND dismiss button. You can modify the Powershell script if this is something you don’t want, but currently it’s restricted like this ๐Ÿ™‚

  16. Hi, congratulations for the job done.
    Is it possible to assign a command like “shutdown -r -t 30” to the action button?

    Thanks a lot and congratulations again
    Nick

    • Hey, and thank you. I’m afraid that the API in Windows doesn’t allow that. The notifications in Windows 10 has very limited actions allowed and running a shutdown command is not one of them. (you are allowed to redirect to other UWP apps, but not run custom code. This is due to security reasons)

  17. FYI
    If you are using Bitdefender Endpoint Security Tools, it really doesn’t like the script.

    It flags New-ToastNotification.ps1 as malware via it’s advanced threat control, because it’s being executed hidden when running as a sheduled task.
    You can instead do something like %comspec% /c start “” /min “C:\ProgramData\ToastNotificationScript\PendingReboot\RunToastHidden.cmd” (edit RunToastHidden.cmd to include an exit), but then it’s not completely hidden when running.

    But Bitdefender also doesn’t like, if you are adding the scheduled task via powershell, instead of via a GPO.

    I’ve opened a ticked with their enterprise support, to see if this can be fixed with the software.

    • Thank you for all the additional details based on your environment. Very interesting and appreciated ๐Ÿ™‚

      • No problem, it’s a neat script ๐Ÿ™‚

        I’ve worked more into the problem, and it appears Bitdefender doesn’t like when executing the powershell scripts unrestricted. So i changed the executepolicy to remotesigned, and that seems to do the trick. Will test a bit further and give a final update on this issue. I guess you could sign the scripts with an internal certificate, to really avoid this issue and run them with AllSigned.

        • And a final note on this issue. Bitdefender has added exclusions for this script to their signature files. That combined with using RemoteSigned, and it’s not a problem anymore ๐Ÿ™‚

  18. Very excited to use this to start nudging my users from 1607 to 1809! Only problem I am having is with an ampersand – which is an unavoidable part of our department name (the line where you have Helpdesk kindly reminding them). Every substitution I’ve tried either makes the dialog fail to display, with the text failing to convert to XML (Error: “‘ ‘ is an unexpected token. The expected token is ‘;’.) or the dialog displays, but with the ampersand missing. I’m thinking maybe I need to double escape it somehow…?

      • I figured it out! Not sure how this site may treat the codes so I will put in some extra spaces, but
        T & amp ; amp ; I
        results in T&I which is what I need.

  19. Hello Martin,

    Is it possible for the toast notification to be movable? Also, sometimes, some parts of the text are not shown because of the display resolution.

    Hope you can check this.

    • The toast notification is native to Windows 10 and to my knowledge, it’s not possible to move any toast generated in Windows 10. I haven’t tested weird resolutions/zoom levels I’m afraid, but I will when I get the chance. Thanks for the feedback ๐Ÿ™‚

  20. Nice. Got it to work

    Nice feature would be multi language. Let the script look at the language settings a user has and apply the correct configuration. If the language is not in a configuration file then use English ( or a default language in configuration)

    We have device all over the world. I now put the correct configuration file (translated) on the device of the user trough a GPO attached to the country OU for that user. But there are some user that are in example Dutch OU but speak only English and have there device set on English.

  21. Is there a way of adding a hyperlink to the toast notification script in the description maybe? I’d like to ask users to go to an internal website to take an action. I absolutely love this script! Great job.

  22. Hello Martin!

    I would like to ask, how should I deploy this as a program? It’s a simple application? If yes, then how should I “detect” under SCCM?

    When I deploy it via SCCM, I need something what can “detect” the actual application deployment.

    Should I try with Task Scheduler and simple Powershell script running? Or I should simply push out as a Powershell Script via SCCM?

    Regards,
    Krisztiรกn

  23. Hi Martin,
    Great Job on this, we are about to upgrade to windows 10 1809 and I found your tool. It looks great.

    Is there a way to get it to recognize the swedish letters ร…ร„ร–?
    It worked great in version 1.

  24. Hi Martin,

    I have solved the Swedish letters problem, I just had to Save as with UTF-8 format and then my letters were shown as they should.

    I have another request,
    When I run the script and choose install/upgrade the Software Center opens but hte SC window isnt in focus and hides behind other windows. Is there a way to make the SC window to be on top?

  25. Hi Martin. I am trying to launch powershell localy with my current user and the same if Sccm is runing package with user context than he do not have rights to write log. I am getting this error:
    Access to the path ‘C:\ProgramData\ToastNotificationScript\New-ToastNotification.log’ is denied.
    and also getting this error:
    Toast notification is not enabled. Please check \\server\share\config-toast-reminder.xml file
    in xml file toest is enabled <Feature Name="Toast" Enabled="True"
    When I change in PS ALLPROFILE to APPDATA notification appears.
    SCCm program is runs Only when User is logged on and Run with user rights

  26. I noticed you’ve added Windows 10 Toast Notification Script Reboot Protocol.msi to the package and mentions ToastReboot in the changelog, but no really deeper information about this new feature in documentation. Can you maybe elaborate how it’s intended to be used?

    Thanks.

  27. I recently found that in my own environment the RunToastHidden.cmd needed at -ex bypass added or the Toast wouldn’t appear. YMMV… just putting it out there for anyone else that find the Toast isn’t appearing.

  28. Thanks heaps. Works really well. When deploying this via Config Manager, how often would you schedule the program? Once a day?

  29. Hi Martin

    Firstly my congratulations on such a great upgrade to SCCM’s user communication.

    We’ve been using this for a few months now and was making the upgrade to 1.2 to use the “Restart Now” button.

    All works as before but clicking on the “Restart now” button brings a popup with “You’ll need a new app to open this toastreboot”

    Any ideas and thanks in advance!

  30. Hi, I noticed up above someone posted about adding a hyperlink into it somewhere. I had thought I had asked at one point too. Any chance this is a simple thing to do ?

    I’d like to have a link that users can click on for more information or instructions if possible.

    • Yeah I saw your request. Should be possible with some teaking. I will look into it. Haven’t tried it yet ๐Ÿ™‚

  31. So I got the whole working with some modifications.

    Notification Popups (with some customization) > its takes to the Assigned OS Upgrade Application on Software Center > the application launches the Upgrade TS.

    The laptop reboots…and after some time I still get the Toast Notification. How can I disable it not to run if Win 10 was upgraded to 1809?

    • Hey, the script is able to run conditionally based on the running OS build. If you set the correct build number in the xml config, the script may run with SCCM but the toast is not shown for the user.

      • ok, I got this working as suggested, Thank you. I had a wrong build number in their.

        Another issue which doesn’t fit in our environment – I noticed, may be again, I missed something. The installation deadline portion.

        When the application in this “https://www.imab.dk/how-can-i-in-place-upgrade-to-windows-10-1803-using-powershell-app-deployment-toolkit-using-the-software-center-in-configuration-manager/” is being deployed as “Deployment – It goes without saying, but the application you just created and the upgrade task sequence intended to run, needs to be deployed (both as available in this scenario).”, how the Toast Notification will run it when you specify your own deadline. In this case, as of writing now, I had the deadline mentioned in Toast Notification for Aug 8th, but the installation did not happen.

        Am I missing something?

        Thanks for your great help.

  32. Hello, thank you for the great script.

    Is it possible to place a link in the text field that points to a company intranet page?

    Many thanks

  33. Great Toast schema, and easy way to make ajustment to the schema. It worked very well with SCCM Configuration Manager, when i copy files to the local system. And made a schedule Task. But I ran into problems if I wanted to make a package that runs in a SCCM schedule. I can see that the package is running on the local system, but I can see that it failed in the ToastNotification log. See

    2019-08-27 10:04:02 INFO: No config file set as parameter. Using local config file
    2019-08-27 10:04:02 INFO: Successfully loaded C:\WINDOWS\ccmcache\11\config-toast.xml
    2019-08-27 10:04:02 INFO: Loading xml content from C:\WINDOWS\ccmcache\11\config-toast.xml into variables
    2019-08-27 10:04:02 INFO: Successfully loaded xml content from C:\WINDOWS\ccmcache\11\config-toast.xml
    2019-08-27 10:04:02 INFO: Creating the xml for no action button and no dismiss button
    2019-08-27 10:04:02 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots. Displaying default toast
    2019-08-27 10:04:02 INFO: All good. Displaying the toast notification
    2019-08-27 10:04:02 INFO: Something went wrong when displaying the toast notification.

    What does it means when it write that error at the last line of the log file ??

    It is something to do with the ExecutionPolicy in the command line ?? Or that it is missing the Toast config file. My Command line is the same, but without the config parameter. See

    powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1

    When I run it fra the local system it works. What is wrong ?

    • Supply to the content above

      Sccm : Program can run : Only when a user is logged on
      The Run mode is : Run with administrative rights
      No mark in : Allow users to interact with this program

Leave a Comment

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