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, Microsoft Intune and scheduled tasks.

The script comes with 3 main purposes/features, but is not limited to:

  • UpgradeOS
  • PendingReboot
  • ADPasswordExpiration

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-users into a voluntary participation and make them initiate the in-place upgrade themselves. This works for both task sequences and feature updates.

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

PendingReboot 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.

PendingReboot is also capable of considering the uptime of the computer. When the uptime exceeds the value defined in the config.xml, the toast is displayed reminding users to restart more often.

ADPasswordExpiration is the third feature checking for local active directory password expiration. If the password is about to expire (days configured in config.xml), the toast notification will display reminding the users to change their password.

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.

I have included several configuration samples in the download; one for use with Windows Servicing, one for checking for pending reboot, one for AD password expiration and another for upgrading Office.

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 AppData\Roaming\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.

Running the Script

How you run the script is mentioned in details in the documentation.  In short, this is simply done using Powershell. Here’s a few examples:

  • .\New-ToastNotification.ps1 -Config .\config-toast-osupgrade.xml
  • .\New-ToastNotification.ps1 -Config .\config-toast-adpwexpiration.xml
  • .\New-ToastNotification.ps1 -Config “\\Server\Share\config-toast-rebootpending.xml”
  • .\New-ToastNotification.ps1 -Config “https://krpublicfiles.blob.core.windows.net/toastnotification/config-toast-whfb.xml”
  • .\New-ToastNotification.ps1 (running it without parameter will default into -Config .\config-toast-xml)

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 contributions from @SuneThomsenDK @ https://www.osdsune.com
      • Date formatting in deadline group
      • Fixed a few script errors
      • More text options
  • 1.4 – Added new feature for checking for local active directory password expiration
    • If the password is about to expire (days configured in config.xml), the toast notification will display reminding the users to change their password.
      • Using this feature requires the ActiveDirectory powershell module
      • The function will try to import the AD powershell module, look up the user’s SamAccountName and use that with the Get-ADUser cmdlet
  • 1.4.1 – Get-ADPasswordExpiration function modified to not requiring the AD Powershell module. Thank you @ Andrew Wells
    • Improved logging for when no toast notifications are displayed
  • 1.4.2 – Bug fixes to the date formatting of ADPasswordExpiration now correctly supporting different cultures
  • 1.4.3 – Some minor corrections to the Get-GivenName function when retreiving first name from WMI and registry
    • Moved the default location for New-ToastNotification.log file to the user’s profile (to cater for permissions issues in %programdata%)
    • Added contribution from @kevmjohnston @ https://ccmcache.wordpress.com
      • Added function for retrieving deadline date and time dynamically in WMI with ConfigMgr
  • 1.4.4 – Fixed DynamicDeadline option and conversion to UniversalTime to display the deadline time correctly regardless of timezone
  •   1.5 – Added new option to run task sequences (PackageID) directly from the toast notification action button. Enable the option <RunPackageID> in the config.xml
    • Fixed a few script errors when running the script on a device without ConfigMgr client
  •   1.6 – Added new option to run applications (ApplicationID) directly from the toast notification action button. Enable the option <RunApplicationID> in the config.xml
    • Created Display-ToastNotification function
      • Displaying the toast notification as been trimmed and merged into its own function
    • Created Test-NTSystem function
      • Testing if the script is being run as SYSTEM. This is not supported and will prevent the toast notification from being displayed
    • Converted all Get-WMIObject to Get-CimInstance
      • Get-WMIObject has been deprecated and is replaced with Get-CimInstance
  • 1.7 – Added multi language support. Thank you Matt Benninge @matbg
    • Script and config files now supports multiple languages
      • Note that old config xml files needs to be updated to support this
    • Moved text values in config files from option to the text-section for consistency
  • 1.7.1 – Added 2 new options (LogoImageName and HeroImageName) to the config file, allowing switching of images more easily and dynamically
  • 1.8.0 – Added support for using Windows 10 Toast Notification Script with Endpoint Analytics Proactive Remediation
    • Added support for having config.xml file hosted online
    • Added support for having images used in the script hosted online
  • 2.0.0 – Huge changes to how this script handles custom protocols. Huge thank you to Chad Brower
    • Added Support for Custom Actions/Protocols within the script under user context removing the need for that to be run under SYSTEM/ADMIN
      • <Option Name=”Action” Value=”ToastRunUpdateID:” />
      • <Option Name=”Action” Value=”ToastRunPackageID:” />
      • <Option Name=”Action” Value=”ToastRunApplicationID:” />
      • <Option Name=”Action” Value=”ToastReboot:” />
    • Added Support to dynamically create Custom Action Scripts to support Custom Protocols
    • Added Support for Software (Feature) Updates : Searches for an update and will store in variable
    • Added new XML Types for Software Updates:
      • <Option Name=”RunUpdateID” Enabled=”True” Value=”3012973″ />
      • <Option Name=”RunUpdateTitle” Enabled=”True” Value=”Version 1909″ />
    • Added support for getting deadline date/time dynamically for software updates
      • Configure DynamicDeadline with the UpdateID
  • 2.0.1 – Updated custom action scripts!
    • Moved all custom action scripts into the user’s profile in $env:APPDATA\ToastNotificationScript
      • $env:ALLUSERSPROFILE was used previously. This is a bad location if device is used by multiple users due to permission issues
    • Updated all custom action scripts to invoke their respective action via WMI
      • Rewritten all custom action scripts
    • Added logic allowing new custom action scripts to be created if necessary
      • Now checks script version in registry
      • If newer version is available from the script, new custom action scripts will be created
        • This allows me to make sure the relevant scripts are in place in case I change something along the way
    • Modified script output of custom script for RunPackageID to pick up Program ID dynamically
  • Added support for getting deadline date/time dynamically for applications
    • Configure DynamicDeadline with the Application ID
  • 2.0.2 – Fixed an error in the custom protocols
    • The path to the custom scripts was incomplete

Troubleshooting Tips

  • The script needs to run in the current user’s context. Don’t run Powershell as another user and expect the toast notification to show. That goes for when running the toast with ConfigMgr as well. It needs the user’s context to display the toast notification for the logged on user.
  • There are combinations in the configuration which doesn’t make sense and I’m preventing most of them. The best advice here is to look on the included configuration examples and stick to those if things are not working.
  • The toast notification has a limit on the sheer size of content. That includes text elements and buttons. You can hit a combination where you have too much text in combination with the snooze option, and you will start seeing the toast rendering without buttons.
  • ConfigMgr admins love log files! Paste the log file as a comment with a few words of your issue, and I can most likely give you the reason for your troubles.
  • Smile 🙂

Download

https://github.com/imabdk/Toast-Notification-Script

Previous Blog Posts

The documentation on the script is currently lacking information. Instead, I suggest you read through some of my previous blog posts, as they are explaining in details, what each new version and capability is offering:

429 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

    Reply
  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!

    Reply
    • 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.

      Reply
  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

    Reply
    • 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 🙂

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

    Thanks

    Reply
    • 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.

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

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

    Reply
    • 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. 🙂

      Reply
  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

    Reply
  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.

    Reply
    • Hey, I attach two images in the download. Take a look at the the sizes of those and you have a good idea. 🙂

      Reply
  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?

    Reply
    • 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 🙂

      Reply
  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.

    Reply
  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?

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

      Reply
  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.

    Reply
  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.

    Reply
    • Hello Ralf, I’m afraid that’s not possible due to restrictions in the OS. It’s prevented due to security reasons 🙂

      Reply
  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.

    Reply
  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.

    Reply
    • 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)

      Reply
        • 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.

          Reply
          • 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.

          • I am experiencing this same issue. It works fine out of the box. Issue seems to be when run as part of a program and from a distribution point or from a network share.

          • Don’t run it from a UNC path or directly from DP (which also translates into a UNC path). The XML layout in the toast will break if doing so. Create a package, which downloads the binaries into the CMcache. The config.xml can be located on a network share, UNC path etc., but not the script itself.

          • Martin, thank you for confirming. Might I suggest pointing this out in the SCCM Installation section of your documentation so other may not run into the same issue. Great tool and I am looking forward to using it in my environment.

  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?

    Reply
      • 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

        Reply
    • 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 🙂

      Reply
        • Hi Alvaro, would you be able to share how you were able to hide the dismiss button only?
          Not an expert at scripting at all 🙂

          Reply
          • No scripting skills required in order to do that. Simply configure the DimissButton Enabled to False in the config.xml 🙂

  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

    Reply
    • 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)

      Reply
  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.

    Reply
      • 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.

        Reply
        • 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 🙂

          Reply
  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…?

    Reply
  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.

    Reply
    • 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 🙂

      Reply
  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.

    Reply
  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.

    Reply
  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

    Reply
  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.

    Reply
  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?

    Reply
  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

    Reply
  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.

    Reply
  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.

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

    Reply
  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!

    Reply
  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.

    Reply
    • Yeah I saw your request. Should be possible with some teaking. I will look into it. Haven’t tried it yet 🙂

      Reply
      • Another vote for allowing to have hyperlinks in the toaster text to point to an internal IT Support website. It would be yet another great feature to add to this amazing tool.

        Reply
  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?

    Reply
    • 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.

      Reply
      • 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.

        Reply
  32. I’m finding that when using softwarecenter:Page=OSD for the Action button that Software Center is launched but it is not brought to the front as the active window. It is launched but sits behind other open windows. This is difficult for the user to find. Is there a fix for this?

    Reply
  33. Hi Martin,
    could you please assist me with deploying the toast? Our goal is to distribute notification real time to every active pc – so Script is the best option to deploy toast so i did this Script:
    New-Item -Path “c:\” -Name “Apps” -ItemType “directory”
    New-Item -Path “c:\Apps” -Name “Notifikace” -ItemType “directory”
    Copy-Item “\\srv-sccm\PackageSource\Notifikace\” -Destination “C:\Apps\Notifikace\” -Recurse
    powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -command C:\NemJiApps\Notifikace\David_kamery\New-ToastNotification.ps1 -Config “C:\NemJiApps\Notifikace\David_kamery\config-toast.xml”

    And the resault is, that the toast copies, runs but fails with this in log:
    2019-07-29 10:22:54 INFO: Successfully loaded C:\NemJiApps\Notifikace\David_kamery\config-toast.xml
    2019-07-29 10:22:54 INFO: Loading xml content from C:\NemJiApps\Notifikace\David_kamery\config-toast.xml into variables
    2019-07-29 10:22:54 INFO: Successfully loaded xml content from C:\NemJiApps\Notifikace\David_kamery\config-toast.xml
    2019-07-29 10:22:54 INFO: PendingRebootUptime set to True. Checking for device uptime
    2019-07-29 10:22:54 INFO: Greeting with given name selected. Replacing HeaderText
    2019-07-29 10:22:54 INFO: Running Get-GivenName function
    2019-07-29 10:22:55 INFO: No given name found. Using placeholder
    2019-07-29 10:22:55 INFO: Creating the xml for no action button
    2019-07-29 10:22:55 INFO: Toast notification is used in regards to pending reboot. Uptime count is greater than -7
    2019-07-29 10:22:55 INFO: All good. Displaying the toast notification
    2019-07-29 10:22:55 INFO: Something went wrong when displaying the toast notification

    Can you please help me find out how to deploy Toast via Script?
    I am Out of options
    Thank you and have a great day!
    Jiří

    Reply
  34. Hi and thank you for the really impressive script and all the explanations!

    Is it possibly possible to insert a hyper link in the text? would like to link to a html page so that users are informed about news.

    Thank you

    Reply
  35. 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

    Reply
  36. 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 ?

    Reply
    • 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

      Reply
  37. Very insterested in 1.4 with the password expiration. When running it, it does not seem to work. Anyone else having similar issues? Was able to make it work after some serious changes, but would like it to work out of the box.

    Reply
  38. What would be the reason why I wouldn’t see the buttons? I’m testing with powershell directly and everything shows except the buttons. It stops at giving me the snooze options. I have the buttons on in the XML. I’m only doing a restart based on a pending reboot. Windows 10 1809. Thanks for any assistance.

    Reply
    • Hey, is that also the case if you use the config-pendingreboot.xml I provide in the download? Sounds like you may have hit the max. cap on text, and if too much text in the actual text boxes, the toast will start removing the buttons.

      Reply
  39. Hi,

    I deploy monthly windows updates using ADR. As I know I cannot put any notification on the ADR.
    Now I want to deploy ONLY a Notification for all users using the script. Can I use and deploy your script to my users ONLY as notification?
    Regards

    Reply
  40. Hi Martin,

    I have tried to change the text in xml file, but it does not work. I get still the originally text notification.
    Any Idea why?

    Best regards

    Keywan

    Reply
    • Hey, are you sure you are modifying the right .xml file? I included multiple examples, but only the config-toast.xml is loaded by default unless you specifically specify another 🙂

      Reply
  41. Hey again,
    I have modified ONLY the config-toast.xml. For example I modified the deadline time and Software Center*www.imab.dk
    But nothing change

    Reply
  42. Hey Martin. Thanks a lot for the great script. I noticed above some people asking for button which can redirect to a website. I also had similar requirment, as in my organization we needed to use Toast notification to share important communication. To achive it, in the cofig xml i changed the and renamed the action button the “Navigate”. So when i click at Navigate, it redirected my to the provided URL.

    Reply
  43. I also had similar requirment, as in my organization we needed to use Toast notification to share important communication. To achive it, in the config xml i changed the line (Action Value=”microsoft-edge:URL)and renamed the action button the “Navigate”. So when i click at Navigate, it redirected my to the provided URL.

    Reply
  44. Martin Bengtsson
    October 2, 2019 at 11:05 am | Reply
    Can you paste the content of the logfile: programdata\Toastnotificationscript\

    Hi Martin,
    I found the Error message. I had open the xml file with papad and forget to select utmf 8.

    Could you tell me please the following questions?

    1) I want to deploy only the notification for user that he can see there are windows or office updates?
    2) If the click on the “Snooze” and select 2 hours, where were it saved on the local machine?
    3) the same question for “Dismiss”?

    Thanks again for help.

    Reply
  45. Awesome script. I did find an issue for my environment using the Get-GivenName function.
    I had to modify line 214 and 217:

    214 – added “select -First 1” because seeing this as array sometimes and since the userSID is the same it works
    $DisplayName = (Get-ChildItem -Path $RegKey | Where-Object {$_.GetValue(“LoggedOnUserSID”) -eq $LoggedOnSID}| Select-Object -First 1).GetValue(“LoggedOnDisplayName”)

    217 – changed split to [1] because our display names are last,first
    $GivenName = $DisplayName.Split()[1].Trim()

    Reply
    • Wonderful. Thanks for letting me know. I see how the logged on SIDs might return an array and I’ll make sure to fix that for future releases 🙂

      Reply
  46. Hey Martin,

    This is such an awesome script, currently blowing minds with the custom images at my company! I did have one question for you though, I am wondering if there is there a way to get either get the Action button to open a website such as https://passwordreset.microsoftonline.com for the password reset toast, and or add a clickable url link in the body text?

    Thank you!

    Reply
  47. Hi,

    This is a pretty cool feature!!

    Is there a way to remove the notification once the upgrade is completed?

    Is there a way to change the background color from Grey to others.

    Regards,
    Sabari

    Reply
  48. One question. My aim is to run this script as a part of my Win 10 upgrade. I want to run it locally as a task in task scheduler. The reason for this is that some of the upgrades will take place over the internet and we dont have a cloud distribution point (only CMG). I created a SCCM package that is targeted to my deploy collection that creates the task in task scheduler and copies the necessary files to a certain ProgramData folder. I am using “Users” for the “When running the task, use the following user account” but it isnt working. Only users that have admin rights see the notification. Any ideas ?

    Reply
    • Does the script actually run and thus write to the log file? In that case, what does the log file say when running the script through the task scheduler in the users context?

      Reply
      • Found out what was the actual problem. New users that log in to the computer dont have the rights to modify new-toastnotification log file. Seems that the main use case for this script is when a computer has only one user ?

        Reply
        • You can move the log file to a better suited location in the write log function in the first section of the script. Sounds like you want to have a unique log file for each user logging in, thus I’d move it to the users profile 🙂

          Reply
  49. Hi Martin,

    How often check the script the uptime and show the message?
    And where can I configute the interwall? It should popup 3 times during the day.
    Is that possible? If yes how?
    Thanks
    Azam

    Reply
    • Yes, that’s possible. You configure the schedule with Configuration Manager or with the scheduled task depending on your choice 🙂

      Reply
  50. Thanks for replay. with Configuration Manager I can schedule as customer interval for example every 2 Hours. But it popup every 2 hours every day. It should popup only one day but 3 times. With scheduled task I have to do that locally on the machine? How can I do that?
    Thanks

    Reply
  51. Hello Martin,

    super script. Is there anyway to display the “hostname” on the Notification?
    Our Users has two windows client machine, it would be nice to have the “hostname” as well on the Notification

    Thanks

    Reply
  52. Hello, this is amazing!
    We do have one problem in our environment though – powershell constrained language mode. It probably is set by applocker. Wouldn’t want to disable it since it’s good for security. Has anyone any experience with this? What would be the best way to deal with it?

    Reply
    • Yep, having applocker forces constrained language mode. To my knowledge, that won’t work with the content of my script. However, scripts allowed by AppLocker rules, such as scripts in trusted directories or signed by a trusted code-signing certificate, should run in full language mode

      Reply
    • I’m not sure if Windows actually accepts a snooze timer longer than 1 day, but I guess you can modify the content of the script in this case. The snooze timer values are in there with creating the .xml for the toast notification 🙂

      Reply
  53. Hello Mr. Martin,
    I use your script on our company and the user is very satisfied. Many users told me if I can set the machine name of the client in the notification. Because our user has two windows client machines, one is locally and the other is remote machine. It is not easy to know which machine has received the notification.
    Best regards
    Jason

    Reply
  54. Hello Martin,
    I have a issue with script. some client does not receive Notification. I did review some settings on the Client.
    The REG “HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings” and “Microsoft.SoftwareCenter.DesktopToasts” is enabled. I have disabled it and log off and log on and enabled again, no change.
    I try to run on Command line this: C:\Windows\CCM>SCToastNotification.exe “test” “test”, No Notification displayed.
    In Windows under “Notifications & actions” settings applet” the Software Center does not appear.

    On my machine is showing under “Notifications & actions” settings applet” the Software Center, and I can run C:\Windows\CCM>SCToastNotification.exe “test” “test” and it works.

    Login with different user does not work too.

    Do you have any Idea what I can do?
    Best Regards
    James

    Reply
    • Hello,
      Sounds like the SCCM client isn’t properly installed. You can switch to doing the notification with Powershell. That’s done in the config file. Does the script run, when run manually? What does the log file say for the situation where nothing is shown? 🙂

      Reply
      • Hello Martin,
        I have uninsatlled SCCM Client and install again. No change. The Reason is the Software Center. That is not displayed on the “Notifications & actions” settings .
        Maybe I am wrong.
        Regards

        Reply
  55. Hello, the SCCM Client is installed. The Script does not manually too with no error. I have checked on many machines. If the Software center is not showing on the “Notifications & actions” settings applet”, it does not display any message. I run your script with .\New-ToastNotification.ps1 -Config .\config-toast-osupgrade.xml with Powershell. It is runing without any error, but it is not displaying.
    ONLY if the Software Center is showing in “Notifications & actions” settings applet” in windows, then it does work.
    But I dont know hwo I can add the Software center in “Notifications & actions” settings applet”.
    Regards
    James

    Reply
    • What I meant was, that you can switch the notification over to being done with Powershell and not rely on the SCCM client. I can’t tell why the SCCM client isn’t properly registered with some of your devices 🙂

      Reply
          • Thanks again, I did that
            I get that error

            Get-Service : Cannot find any service with service name ‘ccmexec’.
            At C:\users\Nasser\Downloads\ToastNotificationScript1.4.2\New-ToastNotification.ps1:204 char:13
            + if (Get-Service -Name ccmexec) {
            + ~~~~~~~~~~~~~~~~~~~~~~~~~
            + CategoryInfo : ObjectNotFound: (ccmexec:String) [Get-Service], ServiceCommandException
            + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

          • Sorry for wrong error,

            I see in the log file following:

            Error. Conflicting selection in the .\config-toast-osupgrade.xml file
            2019-10-17 20:13:28 WARNING: Error. You need to enable at least 1 app in the config doing the notification. ie. Software Center or Powershell

        • Ok I have disabled them, it is runinig now on the machine without sccm client.
          What does mean for me? What is wrong with sccm client? Waht can I do?

          Reply
          • I don’t know whats wrong with the SCCM client on your devices I’m afraid, but using Powershell as the app doing the notification is just fine 🙂

  56. From the log file: “Something is not right about toast notifications in Windows. The script will run, but toasts might not be displayed”

    Everything else in the log appears fine. Getting the notification the the toast is not displayed. Using SCCM. Any thoughts on what to check that might be preventing the toast display?

    Reply
    • Is that coming from running the script manually or with SCCM?

      That line in the log file is from checking for the existence of a registry key/value which is normally associated with whether toast notifications are enabled or not in the OS. If you search for notifications in your settings app, you will get a bunch of setting related to notifications. This is also the place where you are able to disable/snooze notifications in general.

      Reply
      • Only when running with SCCM package. Went back to “out of box” configs for troubleshooting. Toast displays correctly when running the script manually even though the log file still indicates “something is not right”. Still only getting notification when running with SCCM. I’ve been trying different options within the SCCM package/program/deployment and can’t seem to get it going.

        Reply
        • The “something is not right” is looking for the registry key usually indicating whether notifications are disabled are not, but I realize notifications can be enabled without the key present, which is why I allow the script to continue.

          If the script works manually, it will work when run with configmgr. Are you making sure to run it in the user’s context?

          Reply
          • My program properties are set to “only when a user is logged on” and “run with user’s rights”. Also verified user context in execmgr.log.

            Using command from the documentation: “powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config “\\server\source$\software\ToastNotificationScript\Config\config-toast-osupgrade.xml”

          • Must be the permissions on the share I was using or the fact that it was a hidden share. The log file didn’t indicate there was any problem accessing or loading the .xml but clearly something wasn’t right. The toast displays perfectly when I put the .xml on a different share or in the sccm package.

            Thanks for your help and your work on this script!

  57. Good Morning,

    I’d like to use this toast notification script for reminding users of pending reboots after their windows updates have installed. The updates are deployed via SCCM (1902).

    I have configured the toast notification script as package within SCCM and deployed to a test collection. I can see the package in software center, however as the device is pending reboot it will not run as software center says ‘unable to make changes to your software until the computer is restarted’ if running via software center or if waiting for scheduled ‘required’ time in execmgr.log you get “program is ready but can not be started because package, program is currently running”. You can reproduce this behavior by sending a client notification>restart from the SCCM console.
    The script/package is able to run perfectly if its not sccm/software center requiring a restart (only PendingFileRenameOperations found in registry).

    Is it not possible for it to run whilst the device is pending reboot from SCCM? Wanting to use this temporarily until i’m able to upgrade the platform to 1906 or 1910 and make use of the new built in restart dialogue box functionality.

    Regards

    Reply
  58. Is it possible to adjust toast message duration time?
    Right now it displays til’ user clicks on it, but we would like to change it to 30 seconds.

    Overall this script is awesome!

    Reply
    • Yes, that’s possible from modifying the config file and the option: Scenario. Set this to long instead of reminder and you have it displaying for about 30 seconds.

      Reply
      • Is there currently a way to make it only stop display when a user makes a conscious decision (selecting restart or dismiss). I don’t want my users to have the ease of just clicking the toast notification box and having it vanish. I would like it to persist until they click dismiss or restart. Thanks in advanced

        Reply
        • Doing further research on this page, I have found someone else asked a similar question. It is true that this functionality is native to Windows and can not be overridden?

          Reply
          • Correct. The toast notifications are native to Windows. Similar to any other notification made in Windows, clicking the notification itself is equal to dismissing it. I cannot prevent that.

  59. Thank you, and thank you again for sharing this script. It is a very nice work. Well done!!!!

    My concerns are as follow:
    When I run it with logon user, it fails due to permission.
    Here is the log error:
    PS C:\Users\kdkossiv\Downloads\ToastNotificationScript1.4.2> powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File C:\Users\kdkossiv\Downloads\ToastNotificationScript1.4.2\New-ToastNotification.ps1
    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    powershell.exe : Out-File : Access to the path ‘C:\ProgramData\ToastNotificationScript\New-ToastNotification.log’ is denied.
    At line:1 char:1
    + powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoPro …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (Out-File : Acce…log’ is denied.:String) [], RemoteException
    + FullyQualifiedErrorId : NativeCommandError

    At C:\Users\kdkossiv\Downloads\ToastNotificationScript1.4.2\New-ToastNotification.ps1:132 char:48
    + … FormattedDate $LevelText $Message” | Out-File -FilePath $Path -Append
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

    VERBOSE: Something is not right about toast notifications in Windows. The script will run, but toasts might not be
    displayed
    Out-File : Access to the path ‘C:\ProgramData\ToastNotificationScript\New-ToastNotification.log’ is denied.
    At C:\Users\kdkossiv\Downloads\ToastNotificationScript1.4.2\New-ToastNotification.ps1:132 char:48
    + … FormattedDate $LevelText $Message” | Out-File -FilePath $Path -Append
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : OpenError: (:) [Out-File], UnauthorizedAccessException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

    How can I run it as a system and just select the logged user name to display it on the toast notification?
    When I run it as System or admin it can display because it need a login user. (logs):
    ERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory
    VERBOSE: Creating the xml for displaying both action button and dismiss button
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    VERBOSE: Toast notification is used in regards to pending reboot. Uptime count is greater than -6
    VERBOSE: All good. Displaying the toast notification
    WARNING: Something went wrong when displaying the toast notification
    WARNING: Make sure the script is running as the logged on user

    Reply
    • The script needs the current user’s context. If another user created the log file in programdata, it’s possible that another user won’t be able to write to the file. You can move the log file into the users profile instead, ie. appdata.

      Reply
  60. Hello Martin,

    We’ve carried out a quick test on some Windows 10 version 1511 (10586) clients and the notification is generated less the images and main text. Is this a limitation on the OS version as it certainly works well enough on version 1709 and above?

    Reply
    • Hello, yeah there are certain requirements to minimum 1709. btw, don’t use 1511 – it’s no longer supported 🙂

      Reply
  61. Dear Martin,
    I can only say super job and super script. I agree with other users and would be very nice to have the host name as well.
    many thanks
    Jane

    Reply
  62. Good evining,
    I have asked before some weeks ago about hostname.
    Do you have any news? I would like to have the hostname to display in the notification
    Regards
    Steve

    Reply
    • I will, when I have time to take a look on the entire script again. I’m sorry, I’m not working on the script every day.

      If you are familiar with powershell, you could also do it yourself 🙂

      Reply
  63. Hello,
    I’ve created sccm package and add client program run with administrator rights but it just run the program when the loged user has a local administrator rights. If the user hasn’t a local administrator rights it doesn’t appear toast notification on the user screen. How can i run the program without local admin rights?
    Regards
    Jack

    Reply
  64. Hello Martin,
    If i run the program with user rights. Powershell appeared on the screen and disappeared but toast notification did not appear on the screen. I’ve looked the software center the app seemed retry.
    Regards
    Jack

    Reply
      • 2019-10-29 19:49:45 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
        2019-10-29 19:49:45 INFO: Something is not right about toast notifications in Windows. The script will run, but toasts might not be displayed
        2019-10-29 19:49:45 INFO: Successfully loaded \\sccm16\shared_files\everyone_share\config-toast.xml
        2019-10-29 19:49:45 INFO: Loading xml content from \\sccm16\shared_files\everyone_share\config-toast.xml into variables
        2019-10-29 19:49:45 INFO: Successfully loaded xml content from \\sccm16\shared_files\everyone_share\config-toast.xml
        2019-10-29 19:49:45 INFO: Greeting with given name selected. Replacing HeaderText
        2019-10-29 19:49:45 INFO: Running Get-GivenName function
        2019-10-29 19:49:45 INFO: Given name not found in AD or no local AD available. Continuing looking for given name elsewhere
        2019-10-29 19:49:45 INFO: Looking for given name in WMI with CCM client
        2019-10-29 19:49:45 INFO: Creating the xml for no action button
        2019-10-29 19:49:45 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
        2019-10-29 19:49:45 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
        2019-10-29 19:49:45 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
        2019-10-29 19:49:45 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
        2019-10-29 19:49:45 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
        2019-10-29 19:49:45 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
        2019-10-29 19:49:45 INFO: All good. Displaying the toast notification
        2019-10-29 19:49:45 WARNING: Something went wrong when displaying the toast notification
        2019-10-29 19:49:45 WARNING: Make sure the script is running as the logged on user

        Reply
        • !2019-10-29 19:49:45 WARNING: Make sure the script is running as the logged on user! is the culprit. Don’t run it as system, run as the logged on user 🙂

          Reply
  65. Hi Martin,

    Just stumbled across this, really really usefull but i am stuck, using sccm 1903 the software center “OS” tab does show a ‘share’ icon to get a url to apply to “Action” value=”ToastReboot:” is there another way to generate the url ? i have tried searching online but can find nothing ! My users will need this

    Reply
    • Triggering a TS directly from the toast requires some additional steps. The best approach is to have an application, triggering the TS. This I have covered when using PSADT to upgrade Windows 10. Search on my blog 🙂

      Reply
  66. I’d like to find the scopeID/ApplicationID of a specific Task Sequence so I can link to it directly in the ToastNotifications script but in version 1906 of Configuration Manager there is no longer a link to the Application ID in Software Center and I cannot find the ID in the Configuration Manager console. Do you have any idea how I can retrieve the direct link to a non OS related Task Sequence published under Applications in Software Center? Would make my migration to Office 365 perfect if I could combine it with a shiny toast notification.

    Reply
    • I don’t know of a way where to directly initiate the Task sequence through a protocol based action, but you can do somethin custom calling a script where it’s possible. Take a look at my post about updating windows using PSADT, there’s a script included which does it.:

      Reply
      • I will look into that. Maybe a feature for future versions could be to call s script when pushing the Action button which would make it possible to do a whole lot of other things when using a Toast Notification. So far it’s a great addition.

        Reply
  67. Hi Martin,

    Great script!
    We already use it for ADPasswordExpiration.

    Right now i’m testing the UpgradeOS part.
    The ToastNotification comes up, install is pressed and softwarecenter:Page=OSD opens.

    But here comes the problem.
    In the OSD page we have four task sequences.
    – Install Windows 10 Education incl. Office
    – Install Windows 10 Education without Office
    – Install Windows 7 Enterprise incl. Office (This will shortly be deleted, when Windows 7 get’s out of support).
    – Upgrade to Windows 10 version 1903.

    I’m afraid we will have some users, who’s not sure which task sequence to pick.
    So we risk some users will pick “Install Windows 10 Education”, which will format the disk and install a brand new OS. Instead of upgrading the OS.

    Are there a way to point out the specific task sequence (Upgrade to Windows 10 version 1903)? Or maybe even call the task sequence directly from the powershell script?

    Reply
  68. This sounds awesome!
    Will test them out, however i have a request.
    Is it possible to create one for a collection with low amount of disk space?

    We’ve experienced that some user’s are not good at cleaning their PC’s themselves.
    Would be nice to use this tool to give them a reminder on this especially if you are running windows upgrades

    Reply
    • Sure, that’d be possible. I figure you already have a collection consisting of devices which are running low on disk space. Simply deploy a custom toast to that collection 🙂

      Reply
  69. I get an error 0x1(1) in Software Center every time it tries to install.
    ToastNotification.log doesn’t say anything.
    I assume it has something to do with user rights.
    Tested to run the program with administrative rights, then the Toastnotification log updates.
    The user account have access to the share. Is their anything i’m missing here? Can a regular user even run a PS script?

    I haven’t edited the XML’s so everything is pretty much by default

    Reply
    • Several options: 1) Try to delete the current ToastNotificationScript folder in C:\ProgramData and rerun the package/program. It has to run with user rights. 2) Move the log file into the user’s profile in $env:APPDATA instead. You bypass the execution policy by running it like so: powershell.exe -ExecutionPolicy Bypass

      If the folder/logfile in programdata was created by another user, I have seen this will result in unique permissions on the folder preventing other users to append to the log file. If so, the script will fail horribly 🙂

      Reply
  70. Hi,

    Great script. I am in the process of making changes for our company to have the toast notification appear in the language installed on the computer. We have 19 languages, so i am including the translations for each language in the XML file. Let me know if you are interested in the modifications.

    Reply
  71. So i’ve played a round with this a bit now and seems great so far.
    However i have one issue so far and it might not be something you can help with but i just wanted to hear if you have any suggestions.

    In the XML i’ve modified the Action button to open a specific webpage:
    <Option Name="Action" Value="https://website.com&sys_id=a3f50914db194450165992b8db96192d&quot;
    Can't share the specific webpage but it's only the last part that triggers an error.

    This is from the log: Error message: Cannot convert value "System.Object[]" to type "System.Xml.XmlDocument". Error: "'=' is an unexpected token. The expected token is ';'. Line 22, position 99."

    If i remove the last bit "&sys_id=a3f50914db194450165992b8db96192d" it works. But then it doesn't go to the specific spot on the website as supposed to.

    Do you have any suggestions?

    Reply
  72. Hi Martin,

    I have got the OS upgrade toast to work of sorts, using SoftwareCentreApp I have set scenario to long but none of the text displays. Ii have checked all the formating but all the users get is GreetGivenName followed by the three buttons action, dismiss, snooze ?

    Reply
    • Best advice here must be to start fresh from one of the configs I provide in the download. I’m not sure where the error is, but sounds like you have been messing around with the various options and now hit something unsupported 🙂

      Reply
      • is the actual syntax for “scenario” type=”reminder” “reminder | long” or “reminder | short “, i think i made an error by changing it to “scenario” type = “long” ?

        Reply
  73. Hi Martin,
    thanks for this wonderful notification tool.
    Can you let me know how to clear the toast notification saved to action centre. As after reboot, still has multiple events in the action centre when they use the snooze button. Is it possible to include the command “CreateToastNotifier($Appid).RemoveFromSchedule” in the reboot process Thanks for any input.

    Reply
  74. First of all, I want to see this is a very good script, and thank you for sharing with us!
    My question is that is there a way to instruct the script to use the picture globally?
    example, I have the xml shared out on my test server (the ad password one) and the powershell script I have another pic to use. I also have GPO which is replacing the file on the client, right? For some reason if I don’t have the pic I want on their local pc, it’s not reading off my server correctly which involves no pic.

    So with my testing, it looks like the picture needs to be in both the programdata folder for the client and also on the server. Is that true?

    Thanks again.

    Reply
  75. Hi,

    In newer SCCM builds there’s an option to import PowerShell scripts & execute it on devices by rightclicking on the device. However I suspect SCCM does not do this in user context. Would there be any way around this because we would like to send the toast manually instead of through a scheduler. Would there be a way to have PowerShell check the active user on the computer & then execute itself in that context?

    Reply
    • Correct, that is done in system context. You would have to come up with something to invoke the script as the logged on user. It’s doable, but not something that’s currently baked into the script 🙂

      Maybe that’s not a bad idea for an upcoming version, allowing the script to run from system invoking the logged on user’s context 🙂

      Reply
  76. Hello I am testing the solution in a lab.
    I followed the guides so far.
    When I deploy the package it shows in the log success showing the message.INFO:
    “All good. Displaying the toast notification”
    But I do not see any message.
    Later on when I run it from the SW Center it shows up.
    Do you know what could be the reason?

    Reply
  77. I have spent a few hours trying to figure out if I can control the behavior of when my customer’s click the body of the notification. Currently, if you click it it will either disappear or be moved to the action center. I would like to be able to either keep the notification open and only respond to the action buttons (Install, Snooze, Dismiss), or just open the Software Center. Is this possible?

    Reply
    • The behavior of clicking the notification, regardless of it being on the buttons or not, is native to Windows and not something I can control in the script I’m afraid 🙂

      Reply
      • Hi Martin,

        If a user click on body of the notification, it disappear (Native feature on Windows)
        But it never show again ?

        In case of reminder I would like that the notification show again even if user click on body…
        Is there a way to do this ?

        Reply
        • In order for the notification to show again, you would have to rerun the script. This is where a recurrent schedule comes to play. Dismissing the notification will dismiss that instance of the notification and nothing in Windows will make it return automatically. You will have to trigger another notification for it to show again. Hope that makes sense 🙂

          Reply
  78. This is not critical as this kind of script will probably be deployed in program files or similar:
    if script path contains ampersand (&) script fails when creating toast layout.

    Reply
    • In the attached documentation of the download, there’s an example of using the script with group policy and scheduled tasks 🙂

      Reply
  79. Hi
    I tried it. But it didn’t work. Schedule task is not working. When i run the same arguments using the cmd in that pc. It shows the toast. But when i try to do it with group policy schedule task toast is not showing.

    Reply
    • Are you making sure the scheduled task is running in the user’s context? Are you following the directions I made in the documentation? Is anything logged to the log file?

      Reply
  80. Its working now. But i have another problem. As we configure this for ou which contain client pc’s. and not for the server ou. Same user when login in to servers gives wscript error that hidden.vbs is not in the mention location. As i configure file copy part in computer configuration it does not copy files to servers. So.is there any way to hide this error.

    Reply
    • I’m not sure I follow. If you target this to a specific OU only containing workstations, how is this then run on servers? Are you targeting the GPO to all o your users? Don’t do that 🙂

      Reply
  81. Hi

    In a previous response, you said that you are able to notify a user for pending updates.

    This would be really useful for us. Please could you share the info?

    Thanks in Advance.

    Reply
  82. Hello,
    First of all, thank you for this great job, these notifications are awesome !
    I would have one question regarding the special characters encoding in the “config-toast.xml” file.
    Indeed, for the following line (action button), I am trying to set a “mailto:” link with a body message in arguments. However, it seems it does not like the “&” character (I have already tried to escape it using hexadecimal code and [CDATA] tag but to no avail, unfortunately).

    Here is the line I am trying to use at the moment (using the PowerShell app mode) :

    Have you already encountered this issue in the past ?

    Thanks in advance.

    Reply
    • Hi Fred,

      Did you manage to fix it. i have a same requirement to send e-mail by clicking on the action button.

      Thanks a lot in advance

      Reply
  83. Hello,

    This script works very well except for users who have a duplicate screen.

    I can’t figure out how to handle this by GPO.

    Olivier

    Reply
      • Hi,

        The notification does not appear. To see it, we need to click on the notification center.

        By setting the Focus Assist to DISABLED and deactivating “When I duplicate my screen” it works but it must be done on each profil of each station.
        I am looking for a way to manage this via the registry or a GPO, I have 600 computers concerned with interactive whiteboard.

        Thx

        Reply
        • I see… You are not alone on this one I believe. I don’t think focus assist currently can be managed via registry or gpo. You might need to look into using procmon or similar to locate where the settings are being stored.

          Reply
  84. VERBOSE: Toast notification is used in regards to pending reboot. Uptime count is greater than -6
    VERBOSE: All good. Displaying the toast notification

    Yet I get no toast notification

    Reply
    • Hello, does the toast notification perhaps go straight to the action center? Do you have focus assist enabled by any chance?

      Reply
  85. I really like the look and features this SCCM add-on provides, and having compared a number of possible solutions to manage notifications on our SCCM clients, I decided on trying out your script which I have just downloaded (the latest version of your Windows 10 Toast Notification Script from the Technet Gallery – https://gallery.technet.microsoft.com/Windows-10-Toast-9f228eb1)
    Unfortunately when I extract the zip file my Anti-Virus (Trend Micro) complains that the zip contains the HackTool.VBS.InviBat.A spyware within the ‘hidden.vbs’ file (https://www.trendmicro.com/vinfo/us/threat-encyclopedia/malware/HackTool.VBS.InviBat.A)
    Are you aware of this issue?
    Is the hidden.vbs integral to the Toast Notification script?
    If not, are you able to supply a copy of the Windows 10 Toast Notification Script without the hidden.vbs file?

    Thanks in advance.

    Reply
    • I have heard that before, and the .vbs file is only included if you want to run the script completely silent using group policy. You can ignore the file if you intend to use this solely with configmgr. I’m not sure why some AV’s flag that file as malicious, but I think it’s due to the nature of the file running something silent and off the grid. Note: Defender doesn’t flag it, so I assume most is not running into that issue. Thanks for letting me know though 🙂

      Reply
  86. Hello,
    great Script! Is there an overview for all the actions that can be executed by the ActionButton? I know that the actions are very limited due to the Windows API.

    Reply
    • Thank you! Basically all protocol based actions can be run from the toast’s action button. That also goes for any protocols you may create yourself. Some of my other posts on the topic touches base with this as well. 🙂

      Reply
  87. Hello,

    This script is great and has been really useful for prompting OS upgrades where I’ve used it in the past. However, I’m trying to set this up for user pending reboot prompts. It seems to be working OK but I’m finding an issue where your script does not re-enable software notifications if its been disabled by the user (vis notification settings in control panel).

    I can see your script is checking for and setting the registry value: HKCU\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts to an enabled value of 1. If I turn off software centre notifications through the control panel notifications GUI, then allow the script to renable this registry value it does not re-enable the toast messages. The only way round this I can find is to use the GUI once again to turn notiffcations for software centre off – then back on. Once I have done this I then get the toast notifications displayed again. I have been unable to prevent users disabling software centre notifications via gpo either so I’m not able to use this reliably at the moment. I’m testing on Win 10 1909 with SCCM 1906. Is this something you are aware of? Thanks Nick

    Reply
    • Hi Nick, Martin,

      @Martin well done for this really great job !!

      I have the same issue as @Nick.
      If a user disable notification from GUI, the script set “Enable” registry value to “1” but it’s not efficient…
      The only way to re-enable the notification is to activate it from GUI.

      @Nick, @Martin have you an update about this ?

      Best Regards,
      Clément

      Reply
      • Yes, issue is that the settings is stored in AppData\Local\Microsoft\Windows\Notifications\wpndatabase.db.

        If a notification hasn’t been sent (since the user disabled it), there’s maybe a (of course not supported) way: stop the service WpnUserService, delete/rename the wpndatabase.db file, delete the regkey “HKCU:Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts” and restart the service again – a new db file is created and afterwards the notification can be sent successfully. Disadvantage of course: most of the notification settings are lost. Basically the old/renamed db file could be written back to get the settings back.

        Reply
  88. Hello!

    I’m facing a problem with the notification’s behavior and so far, I was unable to find an answer in the Microsoft Doc and I suspect that what I want to do is impossible. I think that with your experience related to notifications, you might prove me wrong (Or tell me that it’s indeed impossible)

    I’m using your script with the AD password expiration option. The notification is displayed using a scheduled task. I went with a “On logon” trigger at first but many users never disconnect their session and they might never see the notification.
    So I moved to a trigger at a fixed hour, repeated every days. The problem is that is the session is locked when the time for the trigger happens, the notification is not displayed and it’s simply stacked in the Action Center for you to read it. But many people aren’t aware of that feature so I wonder if there’s an option related to notification (I’m not afraid to modify the XML if needed, I could even push a PR after that if I’m successful) that force it to “reappear” somehow when you unlock your session and it had been waiting for you. Or maybe a way to trigger the same kind of notification from the Focus Assist that tells you you have pending notifications.

    Any idea?

    Reply
    • Hello Michael, I think your troubles might come from you preventing notifications to be displayed on the lock screen (and for good reasons), and I’m pretty sure that if the session is locked and a notification is displayed behind the scenes meanwhile, this notification will simply be dismissed directly into the action center. I’m not completely sure, as I haven’t tested this specifically, but I think this must be related to some of the customization that’s available in the OS around notifications in general 🙂

      Reply
      • Thanks for your quick answer Martin.

        I am fiddling with the notification settings a bit as I write this answer and if I can’t find a solution that fits my need, I will go another route. A task scheduled each time the session is unlocked and a registry key from your script to check the last time the notification has been displayed. If it’s today, do not display it again. If it was at least a day before, display the notification and update the last run date in registry.

        A bit more taxing as their might be many triggers a day but the users won’t be harassed in spite of everything. 🙂

        Reply
      • And it’s done. I have added a condition to limit the display of the notification one time per day with the corresponding setting in the XML config file so that it’s a setting that can be used per notifications (If you have more than one running). I still need to add another option to enable / disable this behavior.

        If this is something that you are interested in adding to your script, feel free to send me an email so I can share my modifications with you. 🙂

        Reply
  89. Hi Martin,

    I am having trouble running script as a currently logged on user using SCCM. I have created package with all required files > Created a program with cmd line %winDir%\Sysnative\windowsPowershell\v1.0\Powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -File .\New-ToastNotification.ps1 -config .\config-toast-osupgrade.xml

    Only when a user is logged on > Run mode “Run with user rights”

    Looking at execmgr.log > Program Failed with error code 1

    How do I test this when logged on user don’t have permissions to run scripts?

    Reply
    • Hey, any particular reason for you forcing powershell to launch through sysnative? Also, what does the log file say? The log should be located in AppData\Roaming\ToastNotificationScript\New-ToastNotification.log

      Reply
      • Hi Martin,

        Pls ignore my above comment, it was issue with our Software restriction policy which was stopping PS to run as logged on user.

        Thank you for your Amazing job with notification.

        Reply
  90. Dear Martin, great script.

    is it possible to trigger from your toast Notification directly a specific Task Sequence?

    I assume it should be added at the NAME=Action” Value=”” if yes how to add the command?

    Thank you for your help

    Reply
  91. Hey Martin!

    Love the script and been using it a lot in my environemnt.

    I have a couple of users who never got my Windows 10 Upgrade prompt because they manually disabled notifications in their action center. Didn’t know if you had a way to re-enable notifications (maybe just for software center/powershell)?

    Couldn’t really find a good answer googling away this morning…was hoping you had an answer. Thanks!

    Reply
    • I’m not sure, but I will try to give it a second look. I think I have been looking for it previously without luck. I’ll give it another shot 🙂

      Reply
      • I wrote a little crappy CI to discover if these keys are set or not. It hasn’t been thoroughly tested, but I believe it works. I think it needs a reboot for the keys to start working too.

        #remediation
        $key = ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\PushNotifications’
        $Key2 = ‘HKCU:\Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts’

        $ToastProperty = Get-ItemProperty -Path $key -name ToastEnabled
        $SCproperty = Get-ItemProperty -Path $key2 -Name Enabled -ErrorAction SilentlyContinue

        if ((($ToastProperty -eq $null) -or ($ToastProperty.ToastEnabled -eq “1”)) -and (($SCproperty.Enabled -eq $null) -or ($SCproperty.Enabled -eq “1”))) {
        Write-Host Compliant
        }else {

        New-Item -Path $key -Force
        New-ItemProperty -Path $key -Name ToastEnabled -Value 1 -Force
        New-item -Path $key2 -Force
        New-ItemProperty -Path $key2 -Name Enabled -Value 1 -Force
        New-ItemProperty -Path $key2 -Name ShowInActionCenter -Value 1 -Force

        }

        Reply
    • Also wrote a little section to only display to the user if their session is currently unlocked. This was some feedback given to me by a couple of my users:

      $currentuser = gwmi -Class win32_computersystem | select -ExpandProperty username
      $process = get-process logonui -ea silentlycontinue
      While($currentuser -and $process){

      Write-Host Locked
      $currentuser = gwmi -Class win32_computersystem | select -ExpandProperty username
      $process = get-process logonui -ea silentlycontinue
      start-sleep 60
      }
      sleep 10
      write-host Unlocked

      Reply
  92. Hi Martin!

    Thank you for the great script! We are running into a problem with the notifications and are hoping you can help. Our scenario is this:

    The toast notification is deployed as a package via SCCM and is scheduled to run daily at 3pm checking for pending reboots in the registry/WMI
    We also have monthly Windows updates with a deadline/forced reboot
    Here’s the rub, if the Windows updates are installed and the user snoozes the SCCM reboot dialog box, our custom toast notification stops running.
    Nothing is written to the toast notification log at all however, our execmgr log displays the following error:
    “A duplicate execution request is found for the program Toast Notification”
    Once the user reboots, the toast notifications resume running as scheduled.

    We would like to have Windows updates install automatically and allow the user 3 days before the enpoint is forced to reboot. During this time, we want the custom toast notification to run as scheduled. Is this at all possible?

    Reply
    • Hey Trish,

      We have a similar request as well with regards the 3 days notification prior a reboot.
      Did you get any further with this?

      Reply
  93. I have tried this on a clean OOB machine as well as in our production environment, and in both I am receiving no toast popup. I am sure that I am doing something incorrect, as it looks like everyone else here appears to be getting this to work for them.

    If I download the zip/extract locally on a laptop that was fresh out the box(Win 10 1809), and run the New-ToastNotication.ps1 Should the notification populate? I get a warning stating “Conditions for displaying toast notifications for UpgradeOS are not fulfilled” but the script continues on. I have merged the ToastRebootProtocol reg file as well. Any ideas would be much appreciated. Without actually getting the toast notification windows to populate, I am struggling to get started with troubleshooting.

    Thanks in advance for any help provided.

    Reply
    • Hey, if you do a fresh download and run the New-ToastNotification.ps1 without specifying a config.xml file, the script defaults into using config-toast.xml. This config is configured to look for uptime of the computer and not upgradeOS, so you must have done some editing of the config files already? 🙂

      Also, can you paste the log file from appdata\roaming\toastnotificationscript? 🙂

      Reply
  94. Hello
    Having issues getting the TOAST to display. When I look at my task sequence logs running this script I see an entry during the password expire check steps that states:
    VERBOSE: Something is not right about toast notifications in Windows. The script will run, but toasts might not be
    displayed
    I do not have a GPO prohibiting toast and I ran criteria in the task sequence to run during a log on, everyday.

    Is task sequence the best option for these scripts?

    Reply
    • Can you clarify. Do you run the script coming from a task sequence? task sequences run in SYSTEM context. That will not work, as the script needs the current users context.

      Reply
      • I ran from a program and task sequence. I did also turned off the feature to ask ” which program to open” from office as it was being triggered when I ran it as a program. Is running from a program the best option? I did abandon the task sequence. thank you

        Reply
      • Hello,

        I am a beginner and I have a problem. I would like to directly launch another powershell script from the action button
        I modified this in the file : config-toast.xml

        Should we do it another way?
        Thank you for your reply

        Reply
  95. Would it be possible to insert a countdown of some kind, and then automatically have the actionbutton pressed when the timer run out?

    Reply
    • Hey, not to my knowledge I’m afraid. I have studied the documentation of the toast notification feature within Windows 10 and I haven’t read anything about such feature 🙂

      Reply
  96. Greetings,

    I found this to be a great tool, but I have a question. On the restart button, can you tell me where that file needs to reside or how it calls to the msi file?

    Reason I ask is because we want to reset the time to allow more time for my users if they want to reboot but we also want to add a few more checks for other apps. We are trying to find out the piece of code that has the button call for the cmd.

    Thank you in advance.

    Reply
  97. Maybe I missed it but I don’t think it is implemented yet.

    You can have multiple config files in a folder/package but only one ToastHeroImage.jpg and ToastLogoImage.jpg.
    I want to have different images displayed with the different configs I use but I don’t want to create a new package for every config just because I need another ToastHeroImage.jpg. Might it be possible to make the images customizable in the config-toast.xml so you can have different images in one package? Maybe the image can have the same name as the xml file to make it more easy to see what images corresponds with a xml configuration file? So Config-Toast-Diskspace.xml has a corresponding image of Config-Toast-Diskspace.jpg and Config-Toast-Diskspace-Logo.jpg ? Or add an option in the XML where you can type the name of the used JPG images.

    Reply
    • Thank you for the feedback – I will take that into consideration. For now you will need to create separate packages for the separate purposes 🙂

      Reply
  98. Hi Martin, thank you a lot for the nice Toast UI.

    I have some remarks:

    – Toast Notification is displayed on lock screen. How can i avoid it?
    – Is it possible to get a schedule Button?
    – When i press “snooze” the notification go away and come back after the specific time. It would be nice when the notification remains in the notification center. When the notification pop up for the first time and i do nothing it goes into the notification center.

    Thank you!

    Kind regards
    Andreas

    Reply
  99. Hi! A nice extension would be some requirements check, before the action button could use.

    – VPN is required when the device is on external network (we have a lot of road warriors)
    – Device is on battery and need to be plugged in
    – Storage check

    Best regards
    Andreas

    Reply
  100. Hello, first thx a lot for this really cool notification script ! We’re using it for pending reboots and now we’re trying to use it for the Windows 10 Inplace Upgrade to 1909. During testing and the first wave of pilotusers I’m asking myself how can be ensured (and monitored) that the user REALLY got the notification (for the IPU it’s essential since there’s a deadline) since it’s possible that the user disables the notification for Softwarecenter or also Powershell. Only setting the ‘Enabled’ regkey doesn’t enable the notification again (in the GUI in the system settings it seems to be enabled but it isn’t) – as far as I could find out because this change isn’t written back to the “wpndatabase.db” in the userprofile (%localappdata%\Microsoft\Windows\Notifications).
    Regarding monitoring if the notification has been really sent, it can be achieved via Windows Event Viewer – there you can see if a notification has been sent to the user. This is at least one indicator that something went wrong. (Get-WinEvent -LogName Microsoft-Windows-PushNotification-Platform/Operational | Where-Object {$_.Id -eq 3052 -and $_.Message -like “*Microsoft.SoftwareCenter.DesktopToasts*”} | Select-Object -First 1)
    If a notification hasn’t been sent (since the user disabled it), there’s maybe a (of course not supported) way: stop the service WpnUserService, delete/rename the wpndatabase.db file, delete the regkey “HKCU:Software\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts” and restart the service again – a new db file is created and afterwards the notification can be sent successfully. Disadvantage of course: most of the notification settings are lost. Basically the old/renamed db file could be written back to get the settings back.

    Reply
    • Great thoughts, thank you for sharing those. I’ve spent some time myself into looking on something similar, but came to the conclusion it wasn’t worth the troubles. If user’s are disabling notifications, because there are no way to prevent it, we stick to telling people they can’t do that. If they do regardless, they are the cause for their own troubles. We have managements word for that as well.

      However, your findings are interesting and I will surely be looking into those myself. Again, thank you for taking your time to reply 🙂

      Reply
  101. Hi,
    for the beginning just to say, great work mate!
    I was wondering if you thought about putting custom logs path into the XML customization file rather than ps1? 🙂

    Reply
  102. Hello Martin,

    Thanks for this. I am running this toast notification through task scheduler. I am running this notification everyday at 12:00 p.m. I have deployed the task sequence and deployment type is required and provided the deadline date. There is slightly confusing situation occurred for me. I have created a dummy task sequence to delete this notification. Dummy TS started and deleted the scheduled task but already running notification remains there in the action center. Is there a way to remove this toast notification?

    Thanks,
    Dharmesh

    Reply
  103. Is it possible to determine how long a message is show and how long before a user clicked the action button? Is it possible to capture that into the logs?
    Super neat tool

    Reply
    • I guess some of that info is already logged by the OS itself in the event log: Microsoft-Windows-PushNotifications-Platform/Operational.

      Once my script completes, the OS takes over. Actions taken on the notification itself is logged in above event log, as well as when the notification was shown to the user. Hope that is useful 🙂

      Reply
    • The action button can open a web page yes. Windows does not support having hyperlinks inline in the text fields I’m afraid. 🙂

      Reply
  104. This is a great tool and makes the toast taste better. We have gone through a feature update from 1709 to 1809 and it was painful without user notifications. I was wondering if this tool can be used with Windows Updates and not In-Place task sequences? We found that feature updates are less intrusive but the notifications to the users are poor. Any advice would be greatly received. Cheers

    Reply
  105. I’m currently deploying the PendingRebootUptime to a collection query based on last boot time more than 7 days.
    This ideally works but it’s not 100 % correct as we reuse laptops and therefore they might actually receive the toast as the WQL query can’t look at the uptime. As workaround i’ve made a collection gathering inactive clients and then excluding them from the original collection.
    This works but i guess it’s still not 100 % correct.
    Is there any way to deploy to prod. where it actually only displays if it has exceeded 7 days uptime?

    Reply
    • Hmm, if I get you right, you are relying on the collection and thus hardware inventory. The toast script itself has the ability to look up the computer uptime in real time. Ideally you should simply run the script daily, and if the uptime of the computer – which is being looked up each time the script runs – exceeds the value defined in the config, the toast will display. This is not relying on hardware inventory or any other schedule in the configmgr client.

      Isn’t that what you are looking for? 🙂

      Reply
      • Wow, feeling bad for missing that one. I somehow missed this function in the XML config, so i never modified it and just thought that you would need to base it on query based device collections. It works like a charm after i corrected it 😀

        Reply
  106. Hey, like the toast notification script. In the process of setting it up for my Feature Update deployments. I added some functionality to the 1.6 version. Let me know if you are interested in the code and integrating it.

    When a feature update deployment is used with deadline:
    * Finds feature update by name, ID, or type (specify in xml).
    * Uses the feature update deadline as the “DynamicDeadline”.
    * Displays toast based on update Evaluation State (Reboot|Available – Specify in xml)

    Reply
    • Hey Paul, I’m very much interested!

      Thank you so much for reaching out. This is something I appreciate a lot! Unfortunately the script haven’t made it into GitHub yet, so I would appreciate your changes on an e-mail sent to mab@imab.dk. I hope that’s OK for now, and again, thank you! 🙂

      Reply
  107. Hey, I like your script. Is there anyway to display the machine name or computer name on the script?
    Thanks

    Reply
  108. I’m working on implementing this myself, as a request from our desk is to make the Password Expiration notice super-duper-in-your-face. Is there a way to make the toast not auto-hide to the Notification tray?

    Reply
  109. Hi, cudos for the script. it looks great! I am testing the reboot script and it does opens without no issues. However,when the script open and one click on the reboot bottom, this function does not work and the app selector opens asking what app to use to execute the reboot.

    Reply
    • Hi, have you either installed the custom protocol.msi that comes with the download or have you created the custom protocols yourself? 🙂

      Reply
  110. Hey Guys. I tried using the script but it does not reboot the computer. I did try using the two different methods, the reminder and by clicking on the reboot button. Neither of the two options seems to work. Am I missing.

    Reply
    • In order to enable the toast script to carry out actions, you need the custom protocols that comes with the download. Have you had a look at them? 🙂

      Reply
  111. Good morning,

    Does anyone know how or where to change the wording under the greeting? I can change the URL but i cant find where to change the wording ‘Software Center’.

    Thanks

    Reply
    • Hello, you cannot change Software Center. Windows displays that by default, as this is the actual app triggering the notification. This can be changed to Powershell in the config, whereas this will change in the notification as well. 🙂

      Reply
      • Thank you for the quick reply, not what i wanted to hear but i understand 🙂

        Love this toast notification btw, kudos!

        Reply
  112. little update which I think would be a nice feature, where you can have a custom image per XML file: –

    On the PowerShell add between into the Try statement line 600 (where it gets the XML attributes.
    $CustomHeroImage = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘CustomHeroImage’} | Select-Object -ExpandProperty ‘Image’
    $HeroImage = “file:///$global:ScriptPath/$CustomHeroImage”

    And in the XML file add the following: –

    Reply
  113. Hi,

    Firstly thank you for your work on this.

    I am experiencing this same issue. A Software Center Toast pops up stating “New Notification” for a second or two then disappears

    What did you mean by “Create a package, which downloads the binaries into the CMcache” ?

    I have created a package and enabled “Persist content in the Client Cache” but that didnt resolve the issue, I’ve spent a good few hours trying to understand whats wrong but cant seem to figure out why its not displaying the full notification.

    The log file appears to be fine, no issues other than it skips the reg key check “The script will run but toast might not be displayed”

    Please can you help as I’m a bit gutted I got this far and I’m stuck at this point!

    Thanks again

    Reply
    • Just to add, when I set all buttons to False I now get the images and wording in the Notification but it still disappears within a couple of seconds and this also points to what you said about “Create a package, which downloads the binaries into the CMcache” but I am still struggling with how to achieve this. The package is in the CCMCache folder but the folder name will be different for all devices so how would I reference that folder when attempting to run it via the Program/Package?

      Reply
      • Ignore all of my comments it was my error configuring the Dismiss button with the Scenario setting, its working now in all its glory.

        Just so you know, for me, “long” only seems to be a few seconds with Dismiss button set to False

        Reply
  114. In my organization the value stored in the backup WMI reg key HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Authentication\LogonUI\SessionData is in the format Lastname, Firstname. So when local AD wasn’t available the pop up showed “Good morning Lastname,” instead of “Good morning Firstname”. I modified the powershell script with the following to fix this.

    Removed:
    #$GivenName = $DisplayName.Split()[0].Trim()

    Added:
    $pos = $DisplayName.IndexOf(“,”)
    $GivenName = $name.Substring($pos+1)

    Reply
  115. Hello Martin,

    first of all a big thank you for this tool and for your hard volunteer work for the SCCM community 🙂

    I´m trying to use a toast to inform users to update their O365 installation and the action button should trigger an appropriate package for this operation. From what it looks like, the toast notification part goes as planned, packageid is found and written to registry and RunPackageID is ran. But something then goes wrong and the program does not run.

    Here´s an anonymized take from the logs:

    Toast-Notification Log:

    2020-06-10 12.46.17 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2020-06-10 12.46.17 INFO: The registry key for determining if toast notifications are enabled does not exist. The script will run, but toasts might not be displayed
    2020-06-10 12.46.17 INFO: Successfully loaded \\FQDN\UpdateNotification\config-toast.xml
    2020-06-10 12.46.17 INFO: Loading xml content from \\FQDN\O365UpdateNotification\config-toast.xml into variables
    2020-06-10 12.46.19 INFO: Successfully loaded xml content from \\FQDN\O365UpdateNotification\config-toast.xml
    2020-06-10 12.46.19 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    2020-06-10 12.46.19 INFO: Running Write-PackageIDRegistry function
    2020-06-10 12.46.20 INFO: PackageID: APP0036F was found in WMI as deployed to the client
    2020-06-10 12.46.20 INFO: Writing the PackageID to registry
    2020-06-10 12.46.20 INFO: Creating the xml for displaying both action button and dismiss button
    2020-06-10 12.46.20 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    2020-06-10 12.46.20 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    2020-06-10 12.46.20 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    2020-06-10 12.46.20 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    2020-06-10 12.46.20 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    2020-06-10 12.46.20 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
    2020-06-10 12.46.20 INFO: All good. Displaying the toast notification

    Execmgr.log

    IsTerminalServer: 0, IsSingleUserTS: 1 execmgr 10.6.2020 12.46.23 7336 (0x1CA8)
    GetMergedSWDistPolicy – Could not find the policy in WMI for package APP0036F program * execmgr 10.6.2020 12.46.23 7336 (0x1CA8)
    No optional policy available for program, error 87d02004 execmgr 10.6.2020 12.46.23 7336 (0x1CA8)

    I can run the same program the action button should trigger from the software center correctly. I´ve searched everything I can with the error code from the execmgr.log and implemented the following (cases I found were mostly task sequence related)
    – Deployment was first Available, changed to Required with deadline in distant future -> no help
    – “Run this application from task sequence without being deployed – checked, no help

    Any idea what goes wrong? I also get the same error 0X87d02004 if I try to run you RunPackage.ps1 manually from shell.

    Reply
    • Update: I can run programs if I place it in a Task Sequence and trigger the TS through Toast Notification. Sorry if I´ve missed something in your documentations, but is running single packages with “action” not supported?

      Reply
      • Hmm, I don’t recall having tested the scenario with single packages. They might need to be triggered differently. The RunPackageID option is initially made for task sequences. Have you considered creating the Office 365 installation as an application instead, and use the RunApplicationID option in the config? 🙂

        Reply
        • Thanks for confirming the situation for packages. Converting what I´ve done now to run as package to an application should be possible. Initially I chose package as I did not want to fiddle with detection rules and such, my update just runs O365 setup.exe and then triggers OfficeC2RClient.exe to apply the updated settings.

          Reply
  116. On a small number of machines the toast notification does not show up. I am using software center and it is running in user context. I am using version 1.5. I have verified that “Notifications” are enabled, but noticed that there is no entry for “Software Center”

    Any thoughts? Are there known bugs with notifications on Windows 10 1809? Thanks!!

    2020-06-10 13:43:55 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2020-06-10 13:43:55 INFO: Toast notifications are enabled in Windows
    2020-06-10 13:43:55 INFO: No config file set as parameter. Using local config file
    2020-06-10 13:43:55 INFO: Successfully loaded C:\WINDOWS\ccmcache\ki\config-toast.xml
    2020-06-10 13:43:55 INFO: Loading xml content from C:\WINDOWS\ccmcache\ki\config-toast.xml into variables
    2020-06-10 13:43:55 INFO: Successfully loaded xml content from C:\WINDOWS\ccmcache\ki\config-toast.xml
    2020-06-10 13:43:55 INFO: DynDeadlineEnabled set to True. Overriding deadline details using date and time from WMI
    2020-06-10 13:43:55 INFO: Running Get-DynamicDeadline function. Trying to get task sequence deadline details from WMI and ConfigMgr
    2020-06-10 13:44:01 INFO: PackageID of task sequence successfully retrieved. PackageID is: CMP0117F. Now getting deadline date and time
    2020-06-10 13:44:01 INFO: Deadline date and time successfully retrieved from WMI. Deadline is: 06/11/2020 07:00:00
    2020-06-10 13:44:01 INFO: Greeting with given name selected. Replacing HeaderText
    2020-06-10 13:44:01 INFO: Running Get-GivenName function
    2020-06-10 13:44:02 INFO: Given name retrieved from Active Directory
    2020-06-10 13:44:02 INFO: Creating the xml for displaying both action button and dismiss button
    2020-06-10 13:44:02 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2020-06-10 13:44:02 INFO: All good. Displaying the toast notification

    Reply
    • Hey, does the notification show if you switch over using Powershell as the notifying app? I have heard of some instances where notifications are not displaying if using software center, but they were all related to issues on the client (if software center was not properly installed).

      Windows 10 1809 shouldn’t have any issues that I’m aware of.

      Reply
      • Thanks. I actually switched from Powershell in my pilot group 1 to Software Center in pilot group 2 because we had a few users not getting powershell notifications….I will continue my reasearch!

        Reply
        • Right, the user is actually able to disable the notifications separately for software center and powershell. afaik, no why to prevent that from a management perspective. Is this what’s happening?

          Reply
  117. Hello Martin

    thanks for this great tool. I’ve running and issue … I get the toast notification poping up (OS Upgrade) if I select “Instll now” I see flashing the cmd window … and then nothing happens … The TS package ID is informed … The custom tools are already installed … in fact, I checked the registry keys and are informed, and the folder C:\ProgramData\ToastNotificationScript\ Exists … but no log file is created inside … if I run manually the cmd file from there then the TS starts … but Why is not able the Toast to trigger the cmd file ? and why I have no log file created at this location ? The package is deployed OK and is deployed under user context. I’m able to see the Toast …
    Thanks in advance

    Reply
    • The log file should be in appdata\ToastNotificationScript and not in ProgramData. Any clues in there? If the TS is triggered by running the .cmd manually, running the .cmd from the Install button should be the exact same behavior. What value is registered in the registry here: Computer\HKEY_CLASSES_ROOT\ToastRunPackageID\shell\open\command? It should point to the .cmd file.

      Reply
  118. Hi Martin,

    Thanks for this awesome script!
    I already use it for AD Password Expiration and OS-Upgrade. (FYI. for all my ToastNotification scripts I use your 1.5 version, including the .msi file)

    Due to Covid-19, my company wanted a “pop-up” remembering people to wash hands.
    Therefor i decided to create another ToastNotification program. I decided to use the .xml file called config-toast.xml.

    The script/packages works, and the ToastNotification works.
    But there is a “small” problem. Because in the .xml file I have only enabled the Action button, where I changed the value to “OK”.
    But when people press “OK”, the messages just move to the Action Center. Then you have to open Action Center and press OK again or press the cross.
    I believe this happens because there is no “Action” attached to the Action button.

    Is there a way to avoid this?

    Here is a selection of my .xml file:

    Reply
  119. Probably some amateur-error, but having trouble on initiating PendingRebootUptime -toast.

    After enabling:

    log:
    2020-06-12 14.54.37 INFO: Toast notification is used in regards to pending reboot. Uptime count is greater than -6
    2020-06-12 14.54.37 INFO: All good. Displaying the toast notification

    result:
    empty, generic toast
    SOFTWARE CENTER
    NEW TOAST NOTIFICATION

    Doing this by local powershell-console, as logged-on-user.
    What am i missing?

    Reply
    • I believe something’s amiss in the config. Does it work when running the script directly from the download without modifying anything? The toast itself can act up if you put too much text in there.

      Reply
  120. Hi Martin,

    I love the toast notification, but am wondering if there is an easy way to use it to notify users when there is anything available or required in the software centers? We seem to have low install percentages for available software and until the deadline for required. It would be nice to have something more in a users face than the default balloon popup.

    Thanks!

    Reply
  121. Hey Martin,

    I´ve ran into an issue with the new Version of your script. I think with the 1.6 Version, it is no longer possible to run a package.
    I tried to figure out how the whole thing works an from what i undestand it is like this(for osupgrade): The Toastscript checks if its package or application, promts user, starts something(this is the part I dont understand and i guess here is the error – I only know it needs the the reg key in the classes_root), there the .cmd is written down, the cmd starts the ps1 which then starts the Softwarecenter with some sort of COM-command.
    I ran the Toast script with Application and it works (though i got some errors with the application starting the Task Sequence in the filed-test so I wanted to simplify it and just run the Task Sequence)
    I then changed the .xml to run the package ID, the Logs confirm that the Toast now looks for the package ID and that RunapplicationID is not selceted. But still, it runs the application. After some troubleshooting I just changed the “RunApplicationID” Reg Key entry to run the “RunPackageID.cmd” out of curiosity. And, indeed, this “fixed” the issue.

    So in short: Even though “RunPackageID” is selected, it still runs the “RunApplicationID” Reg Key entry.

    Greetings, Phil

    Reply
    • Greetings! I’m not sure I completely follow, but the action taken on the script is managed via the action attribute, and not from enabling either features. Are you remembering to be switching between ToastRunPackageID and ToastRunApplicationID as an action? 🙂

      Reply
  122. Hello, Wanted to see if you seen an issue where when clicking on the Install option in Toast, the action target app shows “Unknown” status for the application in Software Center so users arent able to install the app because the “Install” option for the app in software center is greyed out. We have tried with diff SoftwareIDs in SoftwareCenter and all apps get the same behavior. The toast works great, but when Toast takes them to software center, they are unable to install, thanks

    Reply
      • Hi Martin, wanted to see if you knew of any workarounds to get it to not show unknown, i sent you a screenshot of our xml file. Please let me know if you see anything off, thanks for your help

        Reply
        • I’m sorry for the very late reply. Vacation mode is on. Did you manage to solve this? So this behavior would also be true, if you simply shared the URL/link to the application via email? So when clicking the link, the app would also have an unknown status?

          Reply
  123. Hello,

    I would like to know if it’s possible: before starting the task sequence there are some conditions for example check the disk space and if it’s too full it suggests to delete some content…

    Do you have a proposal to do this?
    Thanks

    Reply
    • I have something similar explained in a previous blog post where I’m sharing my IPU task sequences. Search for that on the blog 🙂

      Reply
  124. Love the notification! Came back to get the updates and I don’t see the O365 variables any more? Is that no longer supported?

    Reply
  125. So great setup! I have one question how do you get the notification screen to show up with A install button and snooze timer? I can get reboot and dismiss but not install and snooze? In your example it shows all the buttons plus snooze timers? any help please

    Reply
    • If you want a snooze button, enable the snooze button in the config xml. The name of the action button (install, reboot etc.) is also configured in the config xml 🙂

      Reply
  126. Hi Martin
    Great Script. I just start testing i our enviroment. We are not using SCCM but Toast Notification would be a great help anyway.
    Just wondering – why are the xml files the same in version 1.8. Im talking about the notification text. All the xml files contains the text from rebootpending.xml.

    Reply
    • Hey Torben, that is just my copy/paste lazyness. This should only be true for the danish and swedish languages. I figured that one would do their own text anyways and replace mine. It’s the configurations of the individual features that’s relevant 🙂

      Reply
  127. I am an SCCM noob but I am trying to implement this toast notification through SCCM. I get the “Script is being run as SYSTEM” Warning and I can not figure out how to get passed this issue. Can you provide any insight? The package is placed in ccmcache and tries to execute from there.

    Reply
  128. Hi Martin,
    This is an absolutely fantastic solution, one I wish Microsoft would implement into SCCM for notifications!
    I have been using it for a while now and it works great 🙂 I use it to prompt users to restart if required (from uptime or software/patch installation).
    One thing I found, and sharing it in case its helpful, is when Focus Assist is turned ON in Windows, the Toast Notifications wont appear on screen, they go straight to the notification center, which is normal behavior. This can be on because the users turned it on, or in alot of cases gets turned on automatically when in video conference meetings etc.
    I found I could get around this by changing the Toast Scenario from ‘reminder’ to ‘alarm’ in the config xml

    This makes the toast push through focus assist (in any of its states), and still seems to behave as a reminder in that it stays on screen until dismissed. However as it is an alarm, by default it also sounds an audible alert, whatever the default alarm tone is set to on windows 10. I didn’t want this in my scenario. So to make it silent I had to add a line to the XML config sections in the New-ToastNotification.ps1 file as below.

    https://docs.microsoft.com/en-us/windows/uwp/design/shell/tiles-and-notifications/toast-schema#toastaudio it can enable/disable the audio for the toast, or apparently change what’s played – although I couldn’t get that to work in testing.
    Anyway, hope this is helpful, and keep up the fantastic work!

    Reply
    • Hmmmm ok some of the lines didn’t come through, apologies.
      Changing to alarm was meant to have the line from the config xml –
      Option Name=”Scenario” Type=”alarm” Possible values are: reminder | short | long
      and the line in the ps1 xml sections to make it silent was ” audio silent=”true” ”
      /binding
      /visual
      audio silent=”true”/
      actions

      Reply
  129. Hello All,
    Getting a strange error when running the script
    “you’ll need a new app to open this toastrunapplid”
    the strange thing is that i don’t get the error but a couple users do. i ran the script manually on the machine, and the popup works, but when you click install the error pops up. the user( doesn’t work) and i (working) are in the same collection and have the app published to the same collection.
    anyone seen this before?

    Reply
    • This is the action on the action button. On some of my examples in the config.xml files, this is set to ToastRunAppID:. This is a custom protocol I made in Windows manually. You would need to make something similar, if you want the action button to do specific things. What do you want the action button to do in your scenario? 🙂

      Reply
  130. Hello,

    I am a beginner and I have a problem. I would like to directly launch another powershell script from the action button
    I modified this in the file : config-toast.xml

    Should we do it another way?
    Thank you for your reply

    Reply
  131. if you would like the users custom profile picture to display instead of the ToastLogoImage.jpg

    Original
    # Setting image variables
    $LogoImage = “file:///$global:ScriptPath/ToastLogoImage.jpg”

    Replacement
    #Find Users Current ProfilePicture
    Add-Type -AssemblyName System.DirectoryServices.AccountManagement
    $CurrentUser = [System.DirectoryServices.AccountManagement.UserPrincipal]::Current
    $SID = $CurrentUser.Sid.Value
    $FindPicture = Get-Childitem -Path C:\Users\Public\AccountPictures\$SID -Include *-Image192.jpg -Recurse -Force
    $ProfilePicture = $FindPicture.Name
    Copy-Item “$env:systemDrive\Users\Public\AccountPictures\$SID\$ProfilePicture” -Destination “$global:ScriptPath\UserPic.jpg” -Force -PassThru
    $unhide = get-item “$global:ScriptPath\UserPic.jpg” -Force
    $unhide.Attributes=”normal”
    # Setting image variables
    if (Test-Path $global:ScriptPath/UserPic.jpg) {
    $LogoImage = “file:///$global:ScriptPath/UserPic.jpg”
    } else {
    $LogoImage = “file:///$global:ScriptPath/ToastLogoImage.jpg”
    }

    Reply
  132. Hi,
    Although the scenario is selected as reminder (in official document, it says “The notification will stay on screen until the user dismisses it or takes action. On Windows Mobile, the toast will also show pre-expanded. A reminder sound will be played”.),
    notification disappears after 5 minutes, i think that maximum run time for a notification is 5 minutes.
    can you confirm if the working principle is like that?
    Thanks.

    Reply
    • Yeah, I can confirm that. I’m not sure if this is ‘as designed’, but something surely seem to have changed within the OS. 5 minutes is what I’m getting as well.

      Reply
  133. Hello Guys,

    I am really impressed with this Toast notification. but i have some queries to run this on my environment. I need to do the package deployment for end users with this toast notification. I created a Task sequence in this case and inserted the Package ID in the config.xml file. but still its failing and i am not getting pop up on the machine. Any help?

    Reply
    • Hi, can you paste the relevant content of the log file: AppData\Roaming\ToastNotificationScript\New-ToastNotification.log

      Reply
      • So the script is never run properly. I have read your email, and the script should not be run from within a task sequence. A task sequence is running in SYSTEM context unless you actively make an effort in invoking the current user’s context. I recommend that you use a package/program as suggested in the documentation 🙂

        Reply
        • Ok.. I was able to create package and push to the machine and i got the pop up to install also. But when i click on “Install now” its bring the “You’ll need a new app to open this link” searching for app. In the xml file, I provided the package ID and still its not working. Any help please?

          Reply
          • Did you enable the CreateCustomScriptsAndProtocols option in the config.xml? If you want the toast notification to carry out custom actions, you will need scripts located in: ProgramData\ToastNotificationScript. Do you have that? Also, please paste the content of the log file located in AppData\Roaming\ToastNotificationScript

          • Will you be able to provide the step by step instruction if possible please?

            1. We need to install the Windows 10 Toast Notification script custome Action protocol in all user machine first
            2. then need to create customscriptsandprotocols option in config.xml whenever we do the package depoyment?
            3. Do we need to update the runpackageId with package id everytime?

          • Have you got the latest version of the script?

            According to the log, you have not enabled CreateCustomScriptsAndProtocols in the config file. This is required if you want the action button to run the package directly. Also, the package comes out as not deployed to the device. The package should be visible from the Software Center. If this is deployed as required, you need to tick ON ‘Allow the users to run the program independently of assignments’ in User experience tab of the deployment.

  134. Hi Martin. Thank you for posting this notification solution. This is exactly what I’ve been looking for to use with our current Windows 10 upgrade initiative. One question I have on it… while running this on some test VM’s, I’ve noticed every once in awhile scclient will stop responding. When I look in event logs, it looks like it’s related to .Net. Are you aware if there is a specific .Net requirement for the toast notifications? Other than that I receive the pop up just fine and it looks great. Thank you!

    Reply
    • Hi, sounds strange. I’m simply launching the software center with some allowed and supported parameters, nothing fancy. As if you would launch software center from a command prompt or with a shortcut. No special requirements 🙂

      Reply
  135. is there a way for the to make a custom action button that could open network and connections setting or open available wireless networks.?

    Reply
    • Hey, I don’t think you need a custom action for that. Have you tried running this from run: ms-settings:network-wifisettings

      You can put that into the action button without creating anything custom 🙂

      Reply
  136. Hi All, anyone tried base64 encoding the image files stead of reading from disk? Reason I ask is I’m having an issue where the toast images are not show in the toast notification sometimes, but other times the images show up. I think it might be an issue were users do not have rights to read image file path from the c:\windows\ccmcache\… So I’ve encoded the images but having some challenges getting it to work, because I’m still a noob with powershell. How can I do this using the existing ps1?

    Reply
    • I tried base64 encoding of the images and I didn’t like it. The script is getting huge. fyi, you can host the images online as well. The script accept images coming from a http or https URL.

      Reply
  137. Hi. I’m trying to work with the toast notification, but when I execute the script, it shows me a generic toast notification stating either Powershell or Software Center “New Notification” and doesn’t actually show me the toast modal. Any thoughts on fixing that?

    Reply
    • Have you made any changes to the config? Which config are you loading? What does the log file say (appdata\toastnotification)

      Reply
      • I get the same. but it seems to be when I run it from a network share. \\doamin\netlogon\new-toastnotification.ps1 -config \\domain\netlogon\Config-Toast-rebootpending.xml. Message is just small window that says Software Center.

        If I copy the script local with the config in the network share it works normally: c:\new-toastnotification.ps1 -config \\domain\netlogon\Config-Toast-rebootpending.xml give me the full popup with buttons.

        No changes to any of the files.

        Reply
        • Yep, I’m not completely sure why, but that haven never worked. The config may reside on a network share, but the script is supposed to be stored locally. Either by ConfigMgr in the cmcache or somewhere else 🙂

          Reply
  138. I only need the reboot functionality, is there any way for me to have the restart function work on clicking the action button without having to install the .msi?

    Reply
    • Yes, see my latest version (2.0.x). This version doesn’t require you installing anything, but creates the protocols for you.

      Reply
      • Interesting.

        With version 2.0 I downloaded from github to my machine and ran it. Everything worked fine, but when I tried to deploy through SCCM to another machine it still doesn’t work. I get the same result as I would on a machine that doesn’t have the .msi installed. Any idea why this might be?

        Reply
        • UPDATE:

          It seems the scripts aren’t getting put into the AppData\ToastNotificationScript\Scripts folder when I deploy through SCCM. What could be the cause of this?

          Reply
          • Sounds like you are not running this as the logged on user, but as with administrative rights? This is something you need to fix on the program in the environment tab in configmgr.

          • I’m also seeing this same thing. I updated my Program’s Environment to Run Mode – “Run with user’s rights” and still get the same results.

          • Are you certain that, that change in the program now is reflected in the current policy on the client? What version of the script are you using? Can you paste the relevant content of the log file? For good measures, I just re-tested everything coming from configmgr running with user’s rights, and everything is populated nicely into appdata\roaming\toastnotificationscript. (version 2.0.2 of the script)

          • I’m sure it’s something on my end. Here are the logs –

            2020-09-11 09:26:06 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-09-11 09:26:06 INFO: The registry key for determining if toast notifications are enabled does not exist. The script will run, but toasts might not be displayed
            2020-09-11 09:26:06 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-09-11 09:26:06 ERROR: No config file found on the specified location [locally or fileshare]

            Could it be an issue with the way I’m deploying the package?

            On Deployment options –
            “Download content from distribution point and run locally” or should I select “Run program from DP” ?

          • How are you specifying the config.xml file if any? Where is your config.xml located? The script accepts the parameter -config, that accepts both UNC paths as well as files hosted online (http or https). If no config file is set via the parameter, the script assumes that a config file is stored next to the new-toastnotification.ps1 file. 🙂

          • I’m using the 2.0.2 Script…this is the script I’m running in the package. That package is point to a file location with the required files.

            powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config “\\Server\SourceFiles\Toast_Notifications\ToastNotificationScript2.0.2\config-toastpendingreboot.xml”

            So maybe my cmd line is wrong?

          • Does the user running the script have access to that location? The cmdline seems OK, the script just doesn’t get to read the config file and that’s where your troubles are. Can you verify that there’s access to the path and that the config.xml indeed is located there?

        • First, wanted to say thanks for the help Martin!!

          I had the config file named wrong in my cmdfile – “config-toastpendingreboot.xml”
          Should’ve been “config-toast-rebootpending.xml”…guess my brain has already moved onto the weekend.

          Thanks again! Awesome tool!

          Reply
  139. Do you have an update in progress for maybe a generic message sender? I’d like to send a system notification, like planned maintenance is about to start? I can kind of hack up the XML file to make it do something similar but if you have something planned, that would be cool.

    Reply
    • If you are referring to use the script to send out general notifications, you can do that by simply turning off all the features in the xml. If you do that, the notification will work like that. The message configured in the xml will be sent out to the devices.

      Reply
  140. Nick kind of hijacked my questions so I’m going to continue on a new thread here because we are not having the same issue and the reply option is gone on the original post.

    My config file is read perfectly fine, it displays whatever I type in the text portion and it does what I ask. My program is run at the user level and not the admin level. My problem is that the script will create the ToastNotificationScript file in %appdata% but it wont put any scripts inside the folder so when I click the “Restart Now” button there is no script to be run. The way I’m implementing this is by SCCM copying the entire folder onto the user machine using robocopy and then running the script locally.

    Thanks again for all the hard work!

    Reply
    • Can I get you to check the registry in HKCU\Software\ToastNotificationScript and the value of the ScriptAndProtocols registry entry? Scripts and protocols are only created if the value of said registry entry is less than the script version. I do this to only create stuff if really needed. Though if the registry entry got created in your end, but not the scripts, running the script again will not make a difference, as long as the registry key is there. Also, can I get you to paste the relevant content of the log file?

      Reply
      • Hey Korey, sorry about. Now that I look at it my Scripts folder is also empty. My registry value is 2.0.2

        2020-09-11 11:41:27 INFO: Script version: 2.0.2 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols

        Reply
      • Martin,

        I’m not really sure why, but this morning I started working on it and it just decided to play nice. Everything is working properly at the moment. I am happy that it works, a little uneasy because I don’t know the exact problem I was having, but I’ll just monitor it closely and if I discover anything I’ll try to post it here for anyone else to see.

        Your work and dedication to this script is awesome!
        Thanks a bunch!

        Reply
        • Thanks! Don’t hesitate to reach out. I’m very keen on getting rid of any bugs I might have introduced. I can only do so much testing myself and I’m usually blind in that regard.

          Reply
  141. Hi Martin,

    Awesome Stuff !! Thanks for Sharing.

    I tried this in my environment and it works like charm for one Software update. But since we have multiple software updates (available in Software Centre) as a part of our monthly patching. Is it possible to run multiple updates using “Install All” button in Software Centre via this Toast notification ?

    Or it is possible open Updates page in software Centre when user action on Install\Update now?

    Thanks

    Reply
    • Hi Rachna,

      You can send the user’s into the Software Center on the Updates page using this as an action: SoftwareCenter:Page=Updates

      The script is currently not able to enumerate through multiple software updates and install them all. The built in feature to install software updates is mainly targeted for Feature Updates, where there obviously just will be one. 🙂

      Reply
  142. Question about the HeroImage. I added my own image for the ToastLogo and it works but the hero image doesn’t show on my notification. I have the jpg image in the Images folder and referenced correctly in the xml. I have also resized the Hero image to the same size as the ToastHerImageDefault and that didn’t work either.

    Reply
    • Hmm, not sure what to advice. Are you able to share the image with me so I can have a go in my end? I’m not doing anything magically regarding the images, other than just reference them when constructing the actual toast. If not an issue, send me the image at mab@imab.dk and I’ll be happy to have a look.

      Reply
  143. Hi Martin,

    Just a curious question, will there be a way to count how many times user clicks the action or dismiss button on the Toast ? Just to get some idea of user usage / behaviour when toast pop-ups. I know that there’s a task sequence you can run after user clicks the action button but I need that button do something else. What I was thinking is to just have a variable somewhere to keep on increasing the count when a user clicks the action button. Will there be a way?

    -Joan

    Reply
    • Hi Joan, I’m not aware of anything out of the box. It would be easy to implement when using the action button, as you can script anything you like here on top of the actual desired action. As to when interacting with the toast notification in general, there are some information logged into the event log here: Microsoft-Windows-PushNotifications-Platform/Operationa

      Reply
  144. This is great, it does exactly what we want it to do, but I only have one question. I am using osupgrade xml with feature updates specifically 2004, how do i get it so that when i click install it initiates the install from software center?

    Reply
  145. Great Script. I wanted to write for others that might run in a use case where you need to enter a URL protocol that has special characters in it.

    I just figured out how to add ServiceNow KB Article to the toast notification!!!!

    It was a stupid find, but for someone that knows enough XML to get buy I am happy. I have no one to share this with so you have to read.

    The problem is the URL for opening an incident from ITNow or Opening an KB article, there is an & in the URL. That is a special character and needs to be escaped as &

    https://xxx.service-now.com/itnow?id=kb_article&sysparm_article=KB0011111
    which works when done manually, and when the XML file is read into a variable as
    https://xxxx.service-now.com/itnow?id=kb_article&sysparm_article=KB0011111

    However, that variable is read into another XML file that needs the & escaped. The fix is to escape the & twice.
    https://xxx.service-now.com/itnow?id=kb_article&amp;sysparm_article=KB0011111

    I am embarrassed on how long that took me to figure out.

    Dawn

    Reply
    • Thank you Dawn, for sharing that. I do think that someone somewhere in the comments section had the need to include ‘&’ in some of the text, and was required to escape the character with the same technique 🙂

      Reply
  146. Hello
    Some of my machines are not running the script. I noticed in SCCM it states Message ID 10006. Error 1. There are windows 10 1709 or 1809. Can’t figure out why some work and other do not. Nothing in the App discovery or App enforce jump out

    Reply
    • execmgr.log will be the correct log, assuming your are running the script with a package/program. AppDiscovery AppEnforce are for applications. Error 1 could me terminating the script for various reasons. Take a peek at the toastnoficiation.log in appdata\toastnotificationscript. What does it say?

      Reply

Leave a Reply to Keywan Cancel reply

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