Windows 11 Toast Notification Script

Description

The Windows 11 Toast Notification Script enables you to create nice and nifty toast notifications for the logged on user in Windows 10/11. 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
  • 2.1.0 – Added a second action button: ActionButton2
    • This allows you to have 2 separate actions. Example: Action1 starts a task sequence, action2 sends the user to a web page for more info
    • This will require new config.xml files
  • Reworked Get-GivenName function
    • Now looks for given name in 1) local Active Directory 2) with WMI and the ConfigMgr client 3) directly in registry
    • Now checks 3 places for given name, and if no given name found at all, a placeholder will be used
  • Fixed CustomAudioToSpeech option
    • This part haven’t worked for a while it seems
    • Only works properly with en-US language
  • Added Enable-WindowsPushNotifications function // Thank you @ Trevor Jones: https://smsagent.blog/2020/11/12/prevent-users-from-disabling-toast-notifications-can-it-be-done/
    • This will force enable Windows toast notification for the logged on user, if generally disabled
    • A Windows service will be restarted in the process in the context of the user
  • 2.3.0 – Added the Register-CustomNotificationApp function
    • This function retrieves the value of the CustomNotificationApp option from the config.xml
    • The function then uses this name, to create a custom app for doing the notification.
      • This will reflect in the shown toast notification, instead of Software Center or PowerShell
      • This also creates the custom notifcation app with a prevention from disabling the toast notifications via the UI

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:

919 thoughts on “Windows 11 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
    • You decide how often the script runs by running it on a set schedule. That goes for both running with Configmgr and/or scheduled tasks 🙂

      Reply
    • Can you please answer below points.

      a)How this will be deployed?
      (b) When this will be deployed?
      (c) Frequency of the deployments?
      (d) What are the criteria (or) categorized considered to identify machines?
      (e) How the success & failures will be measured?
      (f) what is the Low Level Design construct or PS Script and other deliverables?

      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
        • Hi Thangaselvam,
          Great question. Thing is that I actually don’t know 🙂 Sounds like something I need to study further.

          Reply
          • I came across this same need recently and found that if the notification is constructed differently, tag and group can be added, so that they can be used to remove the notification later. (Hopefully the code below displays okay.)

            In the Display-ToastNotification function, comment out the line:
            [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($App).Show($ToastXml)

            … and add:
            $Load = [Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime]
            $Notification = [Windows.UI.Notifications.ToastNotification]($ToastXml)
            $Notification.Group = “your-group”
            $Notification.Tag = “your-tag”
            [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($App).Show($Notification)

            Then, you can remove the notification later with:
            $toastNotifierHistory = [Windows.UI.Notifications.ToastNotificationManager]::History
            $toastNotifierHistory.Remove(“your-tag”, “your-group”, $App)

            Hope that helps someone, and thanks Martin for this amazing work.

    • 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
    • I have the same problem – After choosing install/upgrade Software Center opens but hides behind other windows. It’s very confusing for users. How to overcome this?

      Reply
      • Yeah, I think this is a Windows/Software Center issue, rather than a script issue. I use Start-Process to launch the software center, passing the -WindowStyle parameter to maximized. I’m not sure I can do much else. It’s like referencing an application via the link in the Software Center. If that is being shared, lets say on an email, I see the Software Center sometimes come up behind other applications as well. 🙁

        Reply
    • Yeah, I think this is a Windows/Software Center issue, rather than a script issue. I use Start-Process to launch the software center, passing the -WindowStyle parameter to maximized. I’m not sure I can do much else. It’s like referencing an application via the link in the Software Center. If that is being shared, lets say on an email, I see the Software Center sometimes come up behind other applications as well. 🙁

      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
  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. Hello,
    Great script got it working perfectly. I’m using it for notifying users to not touch a PC that is currently installing programs in the background. Is there a way to have the notification stay on the screen indefinitely until a user hits the dismiss button. Thanks.

    Reply
  129. 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
      • Hello Andrew, can yoy explain this litt more….. what/why do you change audio silent=”true” En where is this in the .xml ? I do not see it….

        Reply
  130. 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
  131. 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
  132. 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
  133. 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
  134. 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

          • Here is the log file.

            2020-08-28 09:08:13 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 09:08:13 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-08-28 09:08:13 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 09:08:13 INFO: Successfully loaded C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml
            2020-08-28 09:08:13 INFO: Loading xml content from C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml into variables
            2020-08-28 09:08:13 INFO: Successfully loaded xml content from C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml
            2020-08-28 09:08:13 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 09:08:13 INFO: Running Write-PackageIDRegistry function
            2020-08-28 09:08:13 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 09:08:13 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 09:08:13 INFO: Running Get-GivenName function
            2020-08-28 09:08:14 INFO: Given name retrieved from Active Directory
            2020-08-28 09:08:14 INFO: Creating the xml for no dismiss button
            2020-08-28 09:08:14 INFO: Creating the xml for snooze button
            2020-08-28 09:08:14 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 09:08:14 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 09:08:14 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 09:08:14 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 09:08:14 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 09:08:14 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 09:08:14 INFO: All good. Toast notification was displayed
            2020-08-28 09:18:44 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 09:18:44 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-08-28 09:18:44 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 09:18:44 INFO: Successfully loaded C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml
            2020-08-28 09:18:44 INFO: Loading xml content from C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml into variables
            2020-08-28 09:18:45 INFO: Successfully loaded xml content from C:\Users\nxa07227-a\Desktop\Package deployment\config-toast_Packageinstallation.xml
            2020-08-28 09:18:45 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 09:18:45 INFO: Running Write-PackageIDRegistry function
            2020-08-28 09:18:45 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 09:18:45 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 09:18:45 INFO: Running Get-GivenName function
            2020-08-28 09:18:46 INFO: Given name retrieved from Active Directory
            2020-08-28 09:18:46 INFO: Creating the xml for no dismiss button
            2020-08-28 09:18:46 INFO: Creating the xml for snooze button
            2020-08-28 09:18:46 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 09:18:46 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 09:18:46 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 09:18:46 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 09:18:46 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 09:18:46 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 09:18:46 INFO: All good. Toast notification was displayed
            2020-08-28 10:31:05 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 10:31:05 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-08-28 10:31:05 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 10:31:05 INFO: Successfully loaded C:\Windows\ccmcache\5\config-toast_Packageinstallation.xml
            2020-08-28 10:31:05 INFO: Loading xml content from C:\Windows\ccmcache\5\config-toast_Packageinstallation.xml into variables
            2020-08-28 10:31:05 INFO: Successfully loaded xml content from C:\Windows\ccmcache\5\config-toast_Packageinstallation.xml
            2020-08-28 10:31:05 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 10:31:05 INFO: Running Write-PackageIDRegistry function
            2020-08-28 10:31:05 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 10:31:05 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 10:31:06 INFO: Running Get-GivenName function
            2020-08-28 10:31:06 INFO: Given name retrieved from Active Directory
            2020-08-28 10:31:06 INFO: Creating the xml for no dismiss button
            2020-08-28 10:31:06 INFO: Creating the xml for snooze button
            2020-08-28 10:31:06 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 10:31:06 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 10:31:06 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 10:31:06 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 10:31:06 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 10:31:06 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 10:31:07 INFO: All good. Toast notification was displayed
            2020-08-28 10:54:31 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 10:54:31 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-08-28 10:54:31 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 10:54:31 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 10:54:31 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 10:54:31 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 10:54:31 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 10:54:31 INFO: Running Write-PackageIDRegistry function
            2020-08-28 10:54:32 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 10:54:32 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 10:54:32 INFO: Running Get-GivenName function
            2020-08-28 10:54:32 INFO: Given name retrieved from Active Directory
            2020-08-28 10:54:32 INFO: Creating the xml for no dismiss button
            2020-08-28 10:54:32 INFO: Creating the xml for snooze button
            2020-08-28 10:54:32 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 10:54:32 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 10:54:32 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 10:54:32 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 10:54:32 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 10:54:32 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 10:54:33 INFO: All good. Toast notification was displayed
            2020-08-28 10:57:05 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 10:57: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-08-28 10:57:06 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 10:57:06 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 10:57:06 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 10:57:06 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 10:57:06 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 10:57:06 INFO: Running Write-PackageIDRegistry function
            2020-08-28 10:57:06 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 10:57:06 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 10:57:06 INFO: Running Get-GivenName function
            2020-08-28 10:57:07 INFO: Given name retrieved from Active Directory
            2020-08-28 10:57:07 INFO: Creating the xml for no dismiss button
            2020-08-28 10:57:07 INFO: Creating the xml for snooze button
            2020-08-28 10:57:07 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 10:57:07 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 10:57:07 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 10:57:07 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 10:57:07 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 10:57:07 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 10:57:07 INFO: All good. Toast notification was displayed
            2020-08-28 11:05:34 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:05:34 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-08-28 11:05:34 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:05:34 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:05:34 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:05:34 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:05:34 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:05:34 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:05:34 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:05:34 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:05:34 INFO: Running Get-GivenName function
            2020-08-28 11:05:35 INFO: Given name retrieved from Active Directory
            2020-08-28 11:05:35 INFO: Creating the xml for no dismiss button
            2020-08-28 11:05:35 INFO: Creating the xml for snooze button
            2020-08-28 11:05:35 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:05:35 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:05:35 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:05:35 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:05:35 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:05:35 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:05:35 INFO: All good. Toast notification was displayed
            2020-08-28 11:07:30 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:07:30 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-08-28 11:07:30 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:07:30 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:07:30 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:07:31 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:07:31 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:07:31 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:07:31 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:07:31 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:07:31 INFO: Running Get-GivenName function
            2020-08-28 11:07:32 INFO: Given name retrieved from Active Directory
            2020-08-28 11:07:32 INFO: Creating the xml for no dismiss button
            2020-08-28 11:07:32 INFO: Creating the xml for snooze button
            2020-08-28 11:07:32 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:07:32 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:07:32 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:07:32 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:07:32 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:07:32 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:07:32 INFO: All good. Toast notification was displayed
            2020-08-28 11:11:10 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:11:10 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-08-28 11:11:10 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:11:10 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:11:10 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:11:11 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:11:11 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:11:11 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:11:11 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:11:11 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:11:11 INFO: Running Get-GivenName function
            2020-08-28 11:11:12 INFO: Given name retrieved from Active Directory
            2020-08-28 11:11:12 INFO: Creating the xml for no dismiss button
            2020-08-28 11:11:12 INFO: Creating the xml for snooze button
            2020-08-28 11:11:12 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:11:12 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:11:12 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:11:12 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:11:12 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:11:12 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:11:12 INFO: All good. Toast notification was displayed
            2020-08-28 11:18:34 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:18:34 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-08-28 11:18:34 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:18:34 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:18:34 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:18:35 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:18:35 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:18:35 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:18:35 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:18:35 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:18:35 INFO: Running Get-GivenName function
            2020-08-28 11:18:36 INFO: Given name retrieved from Active Directory
            2020-08-28 11:18:36 INFO: Creating the xml for no dismiss button
            2020-08-28 11:18:36 INFO: Creating the xml for snooze button
            2020-08-28 11:18:36 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:18:36 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:18:36 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:18:36 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:18:36 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:18:36 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:18:36 INFO: All good. Toast notification was displayed
            2020-08-28 11:19:04 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:19:04 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-08-28 11:19:04 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:19:04 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:19:04 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:19:04 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:19:04 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:19:04 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:19:04 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:19:04 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:19:04 INFO: Running Get-GivenName function
            2020-08-28 11:19:05 INFO: Given name retrieved from Active Directory
            2020-08-28 11:19:05 INFO: Creating the xml for no dismiss button
            2020-08-28 11:19:05 INFO: Creating the xml for snooze button
            2020-08-28 11:19:05 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:19:05 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:19:05 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:19:05 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:19:05 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:19:05 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:19:05 INFO: All good. Toast notification was displayed
            2020-08-28 11:23:03 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
            2020-08-28 11:23:03 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-08-28 11:23:03 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
            2020-08-28 11:23:03 INFO: Successfully loaded C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:23:03 INFO: Loading xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml into variables
            2020-08-28 11:23:03 INFO: Successfully loaded xml content from C:\Windows\ccmcache\6\config-toast_Packageinstallation.xml
            2020-08-28 11:23:03 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
            2020-08-28 11:23:03 INFO: Running Write-PackageIDRegistry function
            2020-08-28 11:23:04 WARNING: PackageID: PS1004E3 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr
            2020-08-28 11:23:04 INFO: Greeting with given name selected. Replacing HeaderText
            2020-08-28 11:23:04 INFO: Running Get-GivenName function
            2020-08-28 11:23:04 INFO: Given name retrieved from Active Directory
            2020-08-28 11:23:04 INFO: Creating the xml for no dismiss button
            2020-08-28 11:23:04 INFO: Creating the xml for snooze button
            2020-08-28 11:23:04 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
            2020-08-28 11:23:04 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
            2020-08-28 11:23:04 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
            2020-08-28 11:23:04 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
            2020-08-28 11:23:04 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
            2020-08-28 11:23:04 INFO: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying default toast
            2020-08-28 11:23:05 INFO: All good. Toast notification was displayed

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

  135. 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
  136. 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
  137. 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
  138. 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
  139. 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
  140. Hi there,
    Love this script. Wondering if there are options for:

    – Prevent user clicking on the body of the toast which will hide the toast box into action center.
    – Count down timer for OS upgrade

    Reply
  141. 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
  142. 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
  143. 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
  144. 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
  145. 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
  146. 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
  147. 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
  148. 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 be me terminating the script for various reasons. Take a peek at the toastnoficiation.log in appdata\toastnotificationscript. What does it say?

      Reply
      • execmgr : Script for Package:WC2005C4, Program: ADpassword expired failed with exit code 1, Toast notification log has not updated for over a month. that is how I found out about 1/3 of the machines were not executing.

        Reply
  149. Your script is fantastic. Got it working in SCCM but when I downloaded the package 2.0.2 I can’t see the msi to enable a reboot. You mention above that it’s not necessary with this version, can you tell me what value I should have here to force a reboot?

    Also I’ve found for Windows Feature Updates a “normal” reboot won’t start the upgrade, it has to be started with “update and reboot” from the Start Menu, is there anyway of duplicating this functionality.

    Reply
    • Correct, the script in version 2.0.2 has an option in the XML which is called CreateCustomScriptsAndProtocols. If this is enabled, the script will create protocols in registry and scripts here: AppData\Roaming\ToastNotificationScript\Scripts.

      The protocol in Windows which enables you to initiate a reboot from the toast action is ToastReoot, but obviously requires that the scripts and protocols are created by the toast script itself:

      Reply
  150. This is looking really fantastic and will definitely implement in our organization. All features are superb, just got a question:
    Our current Windows 10 upgrade notification is checking for the required packages downloaded in ccmcache prior notifying the user for the upgrade.
    Could you please suggest how can we add such configurations in the toast-notification upgrade script?

    Many thanks in advance!

    Reply
    • So all dependencies of the task seqeuence needs to exist by their package id in the ccmcache. That’s not something the script currently can do, but this would be something you could do with collections if precaching content. So once content successfully has precached, you could do a design where the device moves into another collection, where the toast notification is deployed.

      Reply
  151. Hello

    Thank you for responding. It does not seem to execute when I run the command line outside of sccm. I know it works in sccm since I see the logs updating from the previous day when they run around 9am. So some machine it works others it does not.

    powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config “\\server2012\sources\packages\Windows 10 config\Notification-toast\toast-rebootpending.xml”

    Reply
    • Hello, so if trying to run the script locally on one of the affected devices, nothing happens? In either case, something must be reported, either in the log file (if the script manages to pass that point) or directly in the powershell console. What details can you share with me? 🙂

      Reply
  152. Hi,

    Is there a way to enable notification for PowerShell if a user disable that? as I don’t see an option in the script to check for that other than just Notification in general.

    So if I show a notification to user and they hover on the notification, they can select turn off notification for PowerShell and that get disable, I find the registry for it in the HKCU but deleting it doesn’t seems to work and only take affect if you toggle the switch in the actually notification settings.

    Thanks.

    Reply
    • Yes, issue is that, that setting 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\Powershell” 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
      • That would be a pain, cause I have to check for that registry and if it’s exist do those steps to re-create that file and then run it again.

        Is there a way to block the user from disabling notification for PowerShell so it shows up all the time?

        Reply
  153. Hi Martin,
    First of all – thanks for creating this tool, easy to use, easy to change, for people with very few Powershell knowledge.
    However, if I try to use the reboot option, I can see that it’s showing a dropdown button to snooze, but I don’t see the Snooze, reboot action keys.
    I’m using the latest version 2.0.2.
    I have read through the comments already but did not see this noticed before.

    So what have I done so far:
    created an application with 2 files in there:
    – the config-toast-rebootpending.xml file
    – the New-ToastNotification.ps1
    and the images

    the code for the reboot is this.
    Am I missing something here?
































    Your computer is required to restart due to having exceeded the maximum allowed uptime.
    Reason: Pending reboots was found in registry or WMI.
    Your password will expire on:
    Hey you – wake up. Your computer needs to restart. Do it now.
    Restart now
    Dismiss
    Snooze
    Company name
    The IT Organisation kindly reminds you…
    Your computer needs a restart!
    For security and stability reasons, we kindly ask you to restart your computer as soon as possible.
    Restarting your computer on a regular basis ensures a secure and stable Windows. Thank you in advance.
    Click snooze to be reminded again in:
    Your deadline is:
    Good morning
    Good afternoon
    Good evening
    Minutes
    Hour
    Hours
    Computer uptime:
    days

    Thanks!

    Reply
    • Hey, it’s the extra text from the rebootuptimetext option paired with the snooze option, which makes the toast not render properly. I’m preventing that combination in the next version. Either disable snooze or disable rebootuptimetext 🙂

      Reply
      • Thanks for the info and the fast reply! changed it and now I’m able to snooze.
        One more question if I may: is there a possibility to force a reboot after a specific amount of time?

        Reply
        • Only if you script it yourself somewhere. It’s not something my script currently can do 🙂

          You can do another custom action and protocol, that instead of just firing shutdown /r /r 0, you can change it to something else 🙂

          Reply
  154. Martin – This is absolutely fantastic, thank you for sharing! Here’s my scenario and what’s working in my lab..

    1.) Running the Toast Notification application scenario, I wrapped script into PSADT using the following:
    Execute-Process -Path “powershell.exe” -Parameters “-executionpolicy bypass -WindowStyle Hidden -File `”$dirFiles\New-ToastNotification.ps1`” -Config `”\\server\share\public\ToastNotification\config-toast.xml`””

    2.) In SCCM, the program only runs when a user is logged, run mode is set to Run with user’s rights, and program set to always rerun. I use the command line, Deploy-Application.exe Install Noninteractive.

    3.) Toast notification appears and now trying to test the three scenarios, Install Now, Snooze, Dismiss. Not sure what I should be expecting based on how my SCCM program is set to always rerun.

    Reply
    • Hey, the rerun behavior in configmgr doesn’t interact with the buttons in the toast notification. Dismiss will dismiss the current toast notification, period. Snooze will tell the OS to snooze the toast notification for the specified duration. The OS will then display the toast notification once again. The action button will have the action you specify in the config.xml.

      The rerun behavior will simply rerun your PSADT app again, which will run the toast notification. What’s the reason behind wrapping it into PSADT? 🙂

      Reply
  155. Hi Martin, great work! thanks.

    When running Snooze, where is this written to?
    I am deploying a Feature Update via an application. the Toast is set to run every 4 HRS (always rerun), And also setting it to run ASAP. However setting it to run ASAP it will run but as the application isnt yet present in SW center it wont run with a notification to the user.
    Once the machine has the application (feature Update), over two days a user can get duplicate notifications even after snoozing as a previous notification was snoozed.

    Reply
    • Right, when using snooze, you tell the OS to display the toast notification again after the snooze duration, while the rerun behavior in configmgr will do the same. I don’t have a way to prevent that. Personally I don’t recommend using the snooze option, if you also have a rerun behavior in configmgr that rerun the toast that often. 🙂

      Reply
  156. Hello,
    I’m just updated to the latest version of the script and now for some reason I cant get any of the images to show up for the toast notification. Everything else works perfectly fine besides that. I was using version 1.8.0 of the script before and the logo and hero images showed up fine. I’m not sure if anything changed or the images need to be put a specific folder. I left the images in the Images folder like they are by default and checked the config file to make sure the file name was correct for each picture.
    Thanks,
    Kyle

    Reply
    • That’s weird. Does any of the built in images work for you? Does the images show up, if you don’t change any of the configuration in the .xml and simply run the script as it comes from the download, and only replace the images as the only change?

      Reply
      • So the weird thing is the bultin pictures do not show up but if I change the file name to something else and edit the config xml to reflect the change, they show up just fine. Not sure why. At least I was able to get it working that way. Either way, thanks for the script. Truly awesome :).

        Reply
  157. Is there a easy way to replace all SCCM notifications with this? for all new app pushes it looks like you have to hardcode the package ID.

    Reply
  158. I am in the process of testing this for use with Feature Updates. I have both English and German language computers. Would I need to configuration files with different RunUpdateTitle?

    Reply
  159. Hi Martin,

    Great script!.
    How can I get the “Install Now” and “Snooze” action buttons only?
    Editing the xml file “DismissButtion” value to “False” doesn’t work with Snooze enabled.
    The problem is the “Dismiss” button exits the toast notification ever to return.
    If not possible, then how can the Dismiss button be hidden?

    Thanks Tim

    Reply
    • Thanks Tim.

      The script is currently designed in way, where enabling the snooze option, always enables the action and dismiss button, so there’s no option for you within the config file, you will have to modify the actual script to do that 🙂

      Reply
  160. Hi Martin,

    Awesome script!

    I’m not great with .xml but can I add a website link for users to click on in the notification?

    Also we have computers with French OS, will it automatically translate when deployed to the OS?

    Thanks,

    Kyle

    Reply
    • You can specify a website to open in the action button in the .xml. If you want everything to be in French, you need to add an FR language paragraph, similar to the ones I have added for danish and swedish in the config examples I included.

      Reply
          • Hi Martin,

            1. Is there a character limit ?
            2. Just below where is says good morning, it says “Software Center”, is there a way to change it to something else?

          • There might be a character limit. You will know once the toast notification starts to render without buttons and such.
            Software Center is because I use Software Center as the app initiating the toast. It must be something, it can’t be nothing. The alternative is using Powershell. That’s something you can change in the config.xml as well (UseSoftwareCenter or UsePowershell).

          • Hi Martin,

            Thanks again.

            Is it possible to turn off the ability to click or double click the notification and it disappears?

          • Hi Martin,

            Thanks for all your help so far.

            Is there a way to format the information I place in the config.xml? To make it easier to read? Neater?

  161. Hi Martin,

    1. Is it possible to format with etc?

    2. Is it possible to have a 5 second countdown before the buttons are active to click?

    Reply
      • Hi Martin,

        I’m back.

        Question, I’ve asked to find out if the notification can only display when people login and not on the lock screen.

        Reply
          • Hi Martin,

            I read this statement below and wanted to know if you mean I should be going to the “Data Access” tab in the properties of the package and check off “Copy the content in this package to a package share on distribution points”?

            ___________________________________________

            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.

          • Hi,

            No, what I mean is, that the purpose of the toast notification is something you manage via the config.xml, and the config.xml doesn’t have to be a part of the package in ConfigMgr. So if you decide to change the wording or enable another feature, this is solely done in the config.xml file and the script and package needs no edits. 🙂

          • Oh okay I have a deployment that has the entire package sitting on computers including the config.xml at this time. So I’ve been updating all the DPs. So I edit the config.xml with the change on the PS and then update all the DPs.

            Should I redo the entire package without the config.xml in the package?

          • Your decision 🙂 It’s alright to keep the xml within the package and update DPs as you describe. I just prefer not to. 🙂

          • Yeah, and leave the config files on a file share or upload them somewhere reachable via http(s). I do the latter now, as I don’t what to be dependent on an onprem fileshare. I upload them to blob storage in azure, and reference them via the -config parameter 🙂

  162. Hey Martin, and thanks for the awesome script.
    My question might be a bit odd after having read all the comments here, but I wonder if there is a possibility to scale down the size of the notification?
    I mean I WANT it to be intrusive, so the users get notified (running it as a reminder to restart their computer), but some people thint it’s very big. Especially with the heroimage on top of the actual message.

    I’m guessing it has to do with the templates provided by Microsoft, but I can’t get my head around if there are other templates than “ToastGeneric” to use, and if there are, what they might be called.. 🙂

    Any tips around this?

    Many thanks in advance

    Reply
  163. Hi Martin,

    Once again, thank you for these amazing scripts. Just wanted to ask you, how can i make users to open outlook when they click on the action button defined?

    Reply
  164. Hey Martin, first of all I would like to say that you have built a very useful tool! Thanks for that.

    I have the following problem:

    I use the script for notifying users to install an application. I defined the AppId in the xml as described in documentation.
    The script is scheduled to run at every Login and 9 o’clock every day. My problem is that the notification is also displayed if the application is already installed. Do you have a solution for me? I won’t showing the notification if the software is already installed.

    Thanks!

    Reply
    • Hey, make use of the collections here. Deploy the toast notification script to a collection of devices which doesn’t have said application installed already. Then once the applications gets installed, the devices moves out of the collection and is no longer getting the toast notification. This requires that you run hardware inventory daily, if you run the toast notification daily.

      Reply
  165. Sorry if this was already asked but, is there a way to set a time before the notification is automatically dismissed? I am using it as a reboot reminder and after a weekend or night with the users session locked they will come back having to dismiss 10+ notifications to make it go away. Appreciate any help you can provide.

    Reply
    • Hmm, let me think about this one.

      This usually happens because ConfigMgr has run the program again and again over det weekend. How about not scheduling the script to run during the weekend?

      The toasts are being queued in the action center, and once the first is dismissed, the OS displays the next in line. For now, this seem like an unintended benefit of the behavior with a recurrent schedule and the toast script. 10 toast over the course of a weekend do however seem a bit aggressive.

      You can say, that confimgr and the script simply does what you tells it to do. A toast notification is displayed for each time the script is run with configmgr. I will see if I somehow can avoid this. Let me know what you think about this 🙂

      Reply
  166. Hi Martin,

    Excellent script.

    I tried to use the script, I have updated CreateScriptsAndProtocols as true.

    When i try to execute the script its working fine also I could see .cmd and psi file is creating. but when i click on “Install Now” Nothing is happending.

    Could you please help.

    Reply
        • What do you expect to be happening when clicking the action button? What features within the config.xml do you use? Run task sequence, run application or run package? 🙂 And are any of these deployed to the device?

          Also, paste the entire content of the C:\Users\mab\AppData\Roaming\ToastNotificationScript\New-ToastNotification.log file when answered above questions. 🙂

          Reply
  167. Hi Martin, I had an interesting case where the users machine was off for the past 6 days while he was out of the office over the holiday. When he booted the machine this morning he got the Restart Reminder saying his machine has been up for 25 days. The config file is set to 5 days. The New-ToastNotification.log from this morning reflects the current uptime as 25 days.
    I have the notification deployed with ConfigMgr. I verified that the machine was off in the event logs.
    I’m wondering if this is a timing issue between the PS script running and the ConfigMgr client starting up.
    Thoughts?

    Reply
  168. Hi,

    Scripts are disabled for normal users in our organisation. Is there any way around this by using different permissions etc?

    Thanks

    Reply
  169. First, thanks for the time you’ve spent creating an awesome tool. I can’t tell you how many of my customers integrate this into their MECM worlds to elevate their user experience.
    On to my thought/question…I was asked by a customer about scheduling a daily task to proactively monitor for when new updates are available and present a toast notifying them of that and having the action button launch Software Center on the updates page and initiate the install of all updates prior to the deadline. Currently, at least as far as I can tell, all the logic around updates focuses on an individual update, which of course requires monthly modifications to address them individually.
    I’m not sure if this is something others would find valuable enough to include it in the tool, but in case they would, I’ve written the primary additions needed (staying consistent with the existing scripting approach you’ve taken) to read an additional XML value, query for updates that would be ‘available’, and added the custom registry entries and custom script language for the action button and would like to contribute. I’m still working on the scenario logic that the script currently checks for to find conflicts, but that’s coming. How would I go about sending what I’ve added for you to consider?

    Reply
    • Comments like yours makes it all worth it. Thank you so much for sharing that with me, and in regards to your contribution to the script, you are more than welcome to send over what you have to my email: mab@imab.dk

      Again, thank you so much! 🙂

      Reply
  170. i run the command : .\New-ToastNotification.ps1 -Config .\config-toast-adpwexpiration.xml but kept getting this

    WARNING: This will always enable both action buttons and the dismiss button
    WARNING: Replacing any previous formatting of the toast xml
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    WARNING: Conditions for displaying default toast notification are not fulfilled

    Reply
    • you left out some of the important parts of the log file, saying something about if you have a password expiring within the defined period. If your password is not expiring, the toast will not display 🙂

      Reply
  171. Kudos for the work done here “Windows 10 Toast Notification Script”
    im using the script for os upgrade – when i press the action button to trigger the process runnning the ts
    I get a cmd prompt shortly showing the cmd file created by Write-CustomActionScript i think
    should this cmd not be hidden? or maybe put @echo off so the code executed in the bat/cmd is hidden from the userr

    and again nice work.

    Reply
    • In the nature of cmd being a console application, it cannot be hidden without calling cmd from something like a .vbs script. I did initially consider it, but again, you are clicking and initiating an action, and a short cmd prompt doesn’t bother me much. I’d understand if you’re running something silent for the user, but in this case, the user are aware of an action being initiated.

      Perhaps in the future, I’ll rewrite the custom actions to be initiated silently.

      Thank you 🙂

      Reply
      • did some modification so fit my need line:983
        Now i only get the cmd box without path to the ps1 file maybe add echo “Running Action…”

        [String]$Script = @”
        @echo off
        powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File `”$global:CustomScriptsPath\ToastRunPackageID.ps1`”
        “@
        #”powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File `”$global:CustomScriptsPath\ToastRunPackageID.ps1`””

        Reply
  172. Working with the reboot notifications. Some users are getting the following error when the hit RestartNow:

    You’ll need a new app to open the toastreboot

    Any ideas? And can we get the system to log what happens when the buttons are hit?

    Reply
    • Do the users have any content in this folder: C:\Users\Martin\AppData\Roaming\ToastNotificationScript\Scripts
      What version of the script is being used?
      What if configured as action in the config.xml?
      In registry for those users, try to delete this registry entry: Computer\HKEY_CURRENT_USER\Software\ToastNotificationScript\CustomScriptandProtocols and rerun the script. Does the action button work?

      Reply
      • Sorry for very late reply. I am still in testing, so very few users to work with.
        + Verified that the affected user does not have any content in the Scripts folder.
        + Running v2.0.2
        + I am running 2 deployments with different config files. One for check pending reboot and one for time since last reboot. It is working from SCCM on some machines, not others.
        + There is nothing in HKEY_CURRENT_USER\Software\ToastNotificationScript. I had the user delete the ToastNotificationScript key, but that did not have any affect when it was reran.
        + The action button does not work. It gets the error I mentioned.

        Additionally, I found that none of these keys are getting created:
        • HKEY_CURRENT_USER\Software\Classes\ToastReboot
        • HKEY_CURRENT_USER\Software\Classes\ToastRunApplicationID
        • HKEY_CURRENT_USER\Software\Classes\ToastRunPackageID
        • HKEY_CURRENT_USER\Software\Classes\ToastRunUpdateID

        Reply
        • Hmm, does it work when running the script manually on those devices? What if you take my latest version 2.1.0. Does that make a difference?

          Reply
  173. Hey there,

    I have created my own script for a toast notification. I was trying to find a way to re enable toast notifications if it was disabled by the user. Your script does that with the pushnotification registry key. But here is the problem, if I follow the way you do it even after restarting the WpnUserService, the toast notification will not show up. Does it have to do with the windows version (2009) that I am using?

    Reply
    • I am having the same issue. Except I have the audio part turned on, so that still works but the toast message doesn’t pop up. The only way I have found to fix that is to manually toggle the notifications off and on. There has to be something else we can do to force the toast messages to reactivate and pop up.

      Reply
  174. Bringing in the 2.1 version from 1.6, as there’s some grumbling about the password expiration piece still coming up after the password has expired (and they claim they rebooted). Seems there was a change to direct file paths for images, as was pointing to a logo file (C:\ProgramData\CompanyAssets\logo.bmp), and that no longer works.

    Still a great tool, we’ve had a lot of positive feedback, even if users grumble “do I have to change my password now?”

    Reply
  175. In the instructions, It says to input the UNC path for the XML file if stored remotely. I cannot for the life of me figure out where to insert the UNC path for the xml files in the PowerShell script.

    Reply
  176. Hi Martin,

    When using the notification script with the RunApplicationID parameter, does it check the installation state of the application before displaying the notification? Like if the app is already installed, it doesn’t display the notification.

    Reply
    • Hey Michael, you shared this suggestion on GitHub as well. Currently it does not check if the app is actuall installed, though it checks if it’s deployed to the device. Appreciate the suggestions – thank you 🙂

      Reply
      • Hi Martin,

        Did I really shared this suggestion? I don’t even remember. Well, I guess I will try to exercise my memory a bit more before asking new questions. 😅

        And if I find some time for that, I will work on adding this feature and make a PR once it’s ready.

        Reply
        • Hi,

          is there any news on implementing this feature?

          This would be really helpfull in avoiding useless pop-ups and improving the customer experience.

          regards

          Reply
          • I need the same functionality so I did this really quick workaround. Add this from line 660:

            try {
            $TestApplicationIDState = (Get-CimInstance -ClassName CCM_Application -Namespace root\ccm\clientsdk | Where-Object {$_.Id -eq $RunApplicationIDValue}).InstallState
            }
            catch {
            Write-Log -Level Error -Message “Failed to retrieve $RunApplicationIDValue InstallState from WMI”
            }
            #If Application ID State is installed then exit
            if ($TestApplicationIDState = ‘Installed’) {
            Write-Log -Level Error -Message “Script will exit here. Application is already installed”
            Exit 1111
            }

            did not test too much, use at your own risk 🙂

    • I don’t think that’s possible. The body text itself cannot be interactive and the only actions lies within the action buttons I’m afraid.

      Reply
  177. Great work,

    Two suggestions:
    – to show notification under system account serviceui.exe (Part of mdt) could be used I think
    – add support for multiple sccm app installation (if I run second notification for installing another app, registry key with app ID will be replaced right? So the first notification “stops” working. So maybe add some ID param to store settings and custom actions in different location

    Reply
  178. Hei Martin,

    Thanks for the script, nice work!
    One question, I get : waring : conditions for displaying toast notifications for upgradeOS are not fulfilled.

    How can I see whats the problem her, everything seems to be inplace…..

    Mvh John

    Reply
  179. Hei again Martin,

    Is it also possible to run a OS update ?
    When I add the packages ID from the TaskSequens (which available is in the programvarsenter), nothing is happening.

    I’m missing something here as well ?

    Reply
    • The whole point for the toast notification action, is to run a task sequence directly. What action have you defined in the actionbutton option?

      Reply
    • Have you tried running this manually as yourself, with the user you are logged on to windows. Are the folder in appdata created then? When you create the program/package in configmgr, you need to make sure the program is running with user’s rights in the user’s context

      Reply
    • You can enable a snooze option on the toast notification itself, but if the user clicks Reboot now on the action button, the script behind reboots immediately.

      Reply
  180. Hey Martin

    I implemented one of your earlier versions of the toast notification script and i installed ‘windows 10 toast notification script custom actions’. is this particular application still required to utilise custom protocols or can it be now removed?

    Reply
  181. Hello, I’m testing script locally and it works perfectly.

    After creating a package/program in SCCM (user context with all the suggestion given) i can see throug SCCM log files that the exit code is 0, but unfortunately nothing is displayed and no TostNotification.log is created.

    Can you please help me? I’m struggling with this for hours!!

    Reply
    • I would need some more details from you I believe. I exit the script with 0 if the script is run as SYSTEM, or the config is not available and a few other places.

      Reply
  182. Hello Martin!

    Thanks for this awesome script, I have been using it a lot to install feature updates in organisations.
    I was wondering if it would be possible to make a function for the pending reboot actionbutton that installs updates then shuts down the computer when it is finished? I don’t think that the cmd command shutdown /s installs any pending updates?

    Thanks for the awesome work!

    Reply
  183. HI, I was just wondering what I am missing how do I deploy this to devices via sccm. As when I run it in PowerShell no toast message appears.
    Would really appreciate an idiot guide which runs through how to deploy test etc

    Reply
    • What happens when you run New-ToastNotification.ps1 directly from the download on GitHub? If you do so from a powershell prompt, it would log to the screen for you to see what’s happening exactly. That’s the first place to start in troubleshooting this.

      Reply
  184. Hi Again,
    This is a really great script, and thank you again for all the work.
    I had posted awhile back about the notification showing the wrong amount of uptime. I’ve had a couple users who boot the machine up, and it shows a huge number of uptime in days. Today a machine showed being up for 63 days after the boot up.
    Where is this pulling the uptime from? And how could it be so far off?
    Any help would be appreciated.

    Reply
    • Wow, never heard that before. The uptime is retrieved from WMI: (Get-CimInstance Win32_OperatingSystem).LastBootUpTime

      It then takes the current date (Get-Date) and substracts that from the uptime: Current date – LastBootUptime.

      Perhaps it helps if I use system date formats here. It will use your regional settings to display the date and time for the current date and uptime. Not sure if that can cause any issues if using specific regional settings.

      Reply
      • I does seem really weird. It has occurred on 3 different machines out of about 1800 that this has been deployed to. I was thinking possibly the WMI could be corrupt? Since it has not happened on more machines. Is there some testing I could do that may isolate the issue?

        Reply
        • I would test it manually on the device running that portion of my script which calculates the uptime. Is it persistent? Something rotten must be going on, on those devices.

          Reply
  185. Hello Martin,

    i have question about the burnttoast notification. must the powershell module installed on every devices or can we just deployed from config manager ? kind of regards, Osman

    Reply
  186. Hi

    We have deployed the latest version toast and works fine. If the toast triggers and is ignored with no user interaction and no action buttons used, the toast times out after 10 minutes and disappears. It does not appear in the Win 10 notifications area. It appears it will never trigger again.

    We have set snooze option and that works fine. We have scheduled the deployment via SCCM to rerun at 930A daily if the user dismisses but that also seems to not trigger again.

    Is there a setting that will trigger the toast again if the user ignores and/or dismisses the toast? It would be preferable to configure the toast program rather than running the program on schedule.

    Thank you.

    Reply
    • The snooze option should tell the OS (read this is entirely taken care of by windows itself) to re-display the notification. Other than that, a recurring schedule is needed in order to have the toast to be displayed again if needed. Remember the rerun behavior in configmgr needs to be Always rerun. All of these timings are outside of the scope of the script I’m afraid. This is something the OS does. I just trigger a notification, the rest is left to the OS. 🙂

      Reply
  187. Hi,

    We have created a package as you explained in the documentation but we got an error (exit code 1 in the execmgr, 0x1(1) in Software center).

    This package is configured to run as user rights and the xml file is downloaded together with the ps1, so all the files are in ccmcache.

    If I open a powershell with the same user rights, navigate to that folder and run the same command line, it works well.

    “powershell.exe -ExecutionPolicy Bypass -File .\New-ToastNotification.ps1 -Config .\config-toast-osupgrade.xml”

    Additionally, If I’m logon with an admin account, it works fine using software center.

    It’s pretty weird since I can execute it manually with the same user rights… what else should we check? any thoughts? It seems something is blocking when I’m using SC.

    I’ve tried to search for that folder in programdata as someone else reported here before, but in my case, I don’t have it. This folder always is created in appdata as expected.

    Also, no logs are created when it fails in Software Center.

    Thank you.

    Reply
    • How does your program cmdline looks like? If you keep the .xml wihtin your package, try to rename that to just config-toast.xml and avoid using the -parameter option. Otherwise, use the -parameter option but point to a UNC or online location.

      Reply
      • Hi Martin,

        Thank you, it works by running the ps1 directly without any -parameter option.

        Firstly I used the cmdline as you suggested: “powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden-File .\New-ToastNotification.ps1 -Config myfile.xml” but I got that 0x1(1) error.

        Later I tried to run the powershell directly by using only “New-ToastNotification.ps1 -Config myfile.xml” but I got an error “arguments in original command line .\new toast… doesnt’ match associated command line “C:\windows\syswow64\windowspowershell\v1.0\powershell.exe” -NoLogo -NonInteractive -ExecutionPolicy Bypass” %1″

        Using that one (running ps1 directly) in an application has worked fine but you cannot re-schedule to run every day. I thought to put a detection method to find 20H2 version and let the application deployment cycle to run it every day since the package will fail and will retry the next day… but I would rather to set that program schedule.

        Anyway, finally I used a package without parameters or forcing to use powershell, only executing the ps1 and now it works (it uses the default config-toast.xml as you said).

        I think the root cause in our case was some AV policy because when we open a powershell we got a warning due a constrained mode and I recalled we had other issues in the past.

        Thank you

        Reply
  188. Hello Together, i deployed the Toast Notification as a Package and the TaskSequence with a Deadline to the same Collection. I already reinstalled the SCCM Client on the Device but i do get the Following Error in the LOG: Failed to get deadline date and time from WMI, Please check if there really is a deadline configured, The script is continuing, but the toast is displayed without deadline date and time. The Deadline is visible in Software Center.

    The Full Log File:

    2021-02-16 09:09:12 INFO: ToastNotificationScript registry path not found. Creating it: HKCU:\SOFTWARE\ToastNotificationScript
    2021-02-16 09:09:12 INFO: CustomScriptPath not found. Creating it: C:\Users\User\AppData\Roaming\ToastNotificationScript\Scripts
    2021-02-16 09:09:12 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2021-02-16 09:09:12 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2021-02-16 09:09:12 INFO: Successfully loaded \\XXX\config-toast_1809.xml
    2021-02-16 09:09:12 INFO: Loading xml content from \\XXX\config-toast_1809.xml into variables
    2021-02-16 09:09:12 INFO: MultiLanguageSupport set to True. Current language culture is de-CH. Checking for language support
    2021-02-16 09:09:12 INFO: Support for the users language culture found, localizing text using de-CH
    2021-02-16 09:09:13 INFO: Successfully loaded xml content from \\XXX\config-toast_1809.xml
    2021-02-16 09:09:13 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2021-02-16 09:09:13 INFO: Registry value of ScriptsAndProtocolsVersion does not match Script version: 2.1.0
    2021-02-16 09:09:13 INFO: Creating scripts and protocols for the logged on user
    2021-02-16 09:09:13 INFO: Running Write-CustomActionRegistry function: ToastReboot
    2021-02-16 09:09:13 INFO: Running Write-CustomActionRegistry function: ToastRunApplicationID
    2021-02-16 09:09:13 INFO: Running Write-CustomActionRegistry function: ToastRunPackageID
    2021-02-16 09:09:13 INFO: Running Write-CustomActionRegistry function: ToastRunUpdateID
    2021-02-16 09:09:13 INFO: Running Write-CustomActionScript function: ToastReboot
    2021-02-16 09:09:13 INFO: Running Write-CustomActionScript function: ToastRunApplicationID
    2021-02-16 09:09:13 INFO: Running Write-CustomActionScript function: ToastRunPackageID
    2021-02-16 09:09:13 INFO: Running Write-CustomActionScript function: ToastRunUpdateID
    2021-02-16 09:09:13 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    2021-02-16 09:09:13 INFO: Running Write-PackageIDRegistry function
    2021-02-16 09:09:15 INFO: PackageID: XXX was found in WMI as deployed to the client
    2021-02-16 09:09:15 INFO: Writing the PackageID to registry
    2021-02-16 09:09:15 INFO: DynDeadlineEnabled set to True. Overriding deadline details using date and time from WMI
    2021-02-16 09:09:15 INFO: Running Get-DynamicDeadline function. Trying to get deadline details from WMI and ConfigMgr
    2021-02-16 09:09:15 INFO: RunPackageIDEnabled is True. Trying to get deadline information based on package id
    2021-02-16 09:09:17 INFO: PackageID retrieved. PackageID is: XXX. Now getting deadline date and time
    2021-02-16 09:09:17 ERROR: Failed to get deadline date and time from WMI
    2021-02-16 09:09:18 ERROR: Please check if there really is a deadline configured
    2021-02-16 09:09:18 ERROR: The script is continuing, but the toast is displayed without deadline date and time
    2021-02-16 09:09:18 INFO: Greeting with given name selected. Replacing HeaderText
    2021-02-16 09:09:18 INFO: Greeting with Guten Morgen
    2021-02-16 09:09:18 INFO: Running Get-GivenName function
    2021-02-16 09:09:19 INFO: Given name retrieved from Active Directory: XXX
    2021-02-16 09:09:19 INFO: Creating the xml for no dismiss button
    2021-02-16 09:09:19 INFO: Creating the xml for snooze button
    2021-02-16 09:09:19 WARNING: This will always enable the action button as well as the dismiss button
    2021-02-16 09:09:19 WARNING: Replacing any previous formatting of the toast xml
    2021-02-16 09:09:19 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2021-02-16 09:09:19 INFO: All good. Toast notification was displayed
    2021-02-16 09:23:24 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2021-02-16 09:23:24 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2021-02-16 09:23:24 INFO: Successfully loaded \\XXX\config-toast_1809.xml
    2021-02-16 09:23:24 INFO: Loading xml content from \\XXX\config-toast_1809.xml into variables
    2021-02-16 09:23:24 INFO: MultiLanguageSupport set to True. Current language culture is de-CH. Checking for language support
    2021-02-16 09:23:24 INFO: Support for the users language culture found, localizing text using de-CH
    2021-02-16 09:23:24 INFO: Successfully loaded xml content from \\XXX\config-toast_1809.xml
    2021-02-16 09:23:24 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2021-02-16 09:23:24 INFO: Script version: 2.1.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2021-02-16 09:23:24 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    2021-02-16 09:23:24 INFO: Running Write-PackageIDRegistry function
    2021-02-16 09:23:25 INFO: PackageID: XXX was found in WMI as deployed to the client
    2021-02-16 09:23:25 INFO: Writing the PackageID to registry
    2021-02-16 09:23:25 INFO: DynDeadlineEnabled set to True. Overriding deadline details using date and time from WMI
    2021-02-16 09:23:25 INFO: Running Get-DynamicDeadline function. Trying to get deadline details from WMI and ConfigMgr
    2021-02-16 09:23:26 INFO: RunPackageIDEnabled is True. Trying to get deadline information based on package id
    2021-02-16 09:23:27 INFO: PackageID retrieved. PackageID is: XXX. Now getting deadline date and time
    2021-02-16 09:23:27 ERROR: Failed to get deadline date and time from WMI
    2021-02-16 09:23:27 ERROR: Please check if there really is a deadline configured
    2021-02-16 09:23:27 ERROR: The script is continuing, but the toast is displayed without deadline date and time
    2021-02-16 09:23:27 INFO: Greeting with given name selected. Replacing HeaderText
    2021-02-16 09:23:27 INFO: Greeting with Guten Morgen
    2021-02-16 09:23:27 INFO: Running Get-GivenName function
    2021-02-16 09:23:27 INFO: Given name retrieved from Active Directory: XXXX
    2021-02-16 09:23:27 INFO: Creating the xml for no dismiss button
    2021-02-16 09:23:27 INFO: Creating the xml for snooze button
    2021-02-16 09:23:27 WARNING: This will always enable the action button as well as the dismiss button
    2021-02-16 09:23:27 WARNING: Replacing any previous formatting of the toast xml
    2021-02-16 09:23:27 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2021-02-16 09:23:27 INFO: All good. Toast notification was displayed

    Reply
    • See my latest reply. The deadline is grabbed from WMI as the user via Get-CimInstance -Namespace root\ccm\clientsdk -Query “SELECT * FROM CCM_Program where PackageID = ‘packageid'”. If this is run manually on the device, do you then see a deadline configured?

      Reply
      • So I am seeing the same issue that PackageID was not found in WMI as deployed to the client. But I am seeing the Win10 IPU task sequence in the software center. I have verified the PackageID. When I run that command above, it doesn’t find it. Is something wrong with WMI? Is there a way to fix this?

        Reply
  189. Hello Together,

    i found that the dynamic Deadline in the Toastnotification Script for an InPlace Task Sequence ist not working if in the Properties of an InPlace Task Sequence under Advanced: “Suppress task sequence notifications” is set or enabled. I do wan’t to use the Notification Tool instead of any Task Sequence Notifications. In the Log the following Error is reported: Failed to get deadline date and time from WMI, Please check if there really is a deadline configured, The script is continuing, but the toast is displayed without deadline date and time. If “Suppress task sequence notifications” is disabled it works very well and displays the dynamic Deadline. Does anyone have an idea how to fix this error?

    Best regards,
    snoogarp

    Reply
    • Hm, the toast notification grabs what it’s able to retrieve from WMI as the user. I believe this will require that the task sequence is visible in the SC and ‘allow the user to run the program independently of assignments’ enabled on the experience tab of the deployment of the TS (suppressing notifications shouldnt matter in this case)

      Reply
  190. Hi, thanks for the great script!

    Just wanted to ask, is there a reason I shouldn’t amend the code so that I can have 3 buttons:
    (1)Action 1 – install package, (2) Snooze and (3) Learn More – MS Edge to webpage

    I’m using your script for an OS Upgrade and ideally wanted our users to install now, snooze – to install later, or Learn More taking them to an intranet page about relevant information.

    Obviously, your script prevents 2 actions and snooze being enabled at the same time, so I’ve managed to amend the ps1 to work for what I need by commenting out this small bit of error-handling. But before I start using it with our users thought I would ask the question?
    Thanks again.

    Reply
  191. Good morning @ all.

    First of all, very nice Tool!

    I have 2 Questions:
    1. I created the Package and a program. I deployed the program to a device group within SCCM. Run Mode “Run with user’s rights”, only when a user is logged on. Advanced Setting “Run once for every user who logs on”
    Test result was negative, no notification when users log in.
    2. I tried to test the script directly with powershell. -> .\New-ToastNotification.ps1 -Config .\config-toast.xml
    Script is working, but i do not see the notification layout wich you posted above. I only see a small popup Notification like Softwarecenter New Notification.
    Thanks for your Support

    Reply
  192. Hi Martin,

    Not sure if I’m missing something, I’ve downloaded 2.1.0 version and all the config files are not in English.
    Do you have English version by any chance?

    Reply
  193. Hey Guys,

    i was able to get the script to run! Works perfectly and I’m thrilled! Now, my question is whether it would be possible to define a prerequisite before the script is executed. For other information, whether the IP is reachable by the DC. The background is that I would like to run the script at Logon, but many users are currently @ Home and haven’t set up a VPN immediately when logging in. Thus, the script fails because no DC is reachable. Or do you have a better idea to define a planned task? Thank you in advance

    Reply
  194. hi Martin,
    we are using your script for some months now and it is working great.
    i have only a question , your script counts the days that one pc is not rebooted.
    if the user shutdown the pc every day, after the specified days in the script the notification appears asking the user to reboot.
    is this normal or i missed some settings?

    thank you

    Reply
    • Hi, I’m getting the last boot time from WMI: Get-CimInstance Win32_OperatingSystem. If this somehow is not reset on shut down (I cannot imagine how and why), the script will still count uptime and display the notification. You will need to do some troubleshooting here and look in WMI on the device where this behavior is reported 🙂

      Reply
  195. hi Martin,
    we are using your script for some months now and it is working great.
    i have only a question , your script counts the days that one pc is not rebooted.
    if the user shutdown the pc every day, after the specified days in the script the notification appears asking the user to reboot.
    is this normal or i missed some settings?

    thank you

    Reply
    • Hi, I’m getting the last boot time from WMI: Get-CimInstance Win32_OperatingSystem. If this somehow is not reset on shut down (I cannot imagine how and why), the script will still count uptime and display the notification. You will need to do some troubleshooting here and look in WMI on the device where this behavior is reported 🙂

      Reply
      • Thanks Martin,
        indeed it was a problem with the WMI. i have rebuild the WMI repository and now it seems to work normally.

        Reply
  196. Hi Martin,
    I’m working on configuring your script to work in our domain environment for reboots related to Windows Updates.
    I have it working for the most part. Currently I’m creating a scheduled task per the guide to run hidden, however it’s still popping up a command prompt window as it begins. It wasn’t at first, now it is. Not sure what I’ve done? Any ideas?
    Additionally, I’ve created a GPO that copies the files and creates the scheduled task to run as SYSTEM. Unfortunately, since the changes a couple of years ago that removed the ability to set a dynamic user for the runas of a scheduled task, I’ve had to create a second scheduled task that runs(as SYSTEM): schtasks /change /tn UpdateToastNotification /ru BUILTIN\Users
    This seems to be working, but I’m wondering if you have advice for setting the task to run as the logged on user….
    Thanks for all of you work!

    Reply
  197. Hey Martin,

    Your toast solution looks great. I had a question before for the case when only signed scripts are allowed to run in the environment and I’m basically setting “CreateScriptsAndProtocols” Enabled=”False” and pushing the signed scripts through a GPO to all users, not sure if you have a better suggestion?
    Another question will be, do you think it’s possible to add a logic to display the toast notification only if application/package is not installed? This will help me a lot and will be much appreciated if you can add this to your future releases.

    Thanks.

    Reply
    • No worries. Your suggestion in regards to the signed scripts is identical to what I suggested in your previous question, right? The option you talk about, to only display the toast if the app/package is not installed, is somehow built in. The toast is only displaying if the app/package is deployed and the rest is something collections is better at taking care of 🙂

      Reply
      • Yeh… a bit specific environment here, so I’ve updated the “function Write-ApplicationIDRegistry” as per below and it looks to be working for me, thanks anyway:
        if ($TestApplicationID) {
        Write-Log -Message “ApplicationID: $RunApplicationIDValue was found in WMI as deployed to the client”

        If ($TestApplicationID.InstallState -eq “NotInstalled”) {
        Write-Log -Message “Writing the ApplicationID to registry as it’s not installed”
        if ((Get-ItemProperty -Path $RegistryPath -Name $RegistryName -ErrorAction SilentlyContinue).$RegistryName -ne $RunApplicationIDValue) {
        try {
        New-ItemProperty -Path $RegistryPath -Name $RegistryName -Value $RunApplicationIDValue -PropertyType “String” -Force
        }
        catch {
        Write-Log -Level Error -Message “Failed to write ApplicationID: $RunApplicationIDValue to registry”
        }
        }
        }

        Else {
        If ($TestApplicationID.InstallState -eq “Installed”) {
        Write-Log -Message “Application is already installed and will now exit the scrit”
        Exit 0

        }
        }

        }

        Reply
  198. This is honestly very, very good, the only caveat is it doesn’t check the execution status of the SCEM Package and not run/show the Toast if it was successfully installed. I fear this could be run over and over by users that really aren’t paying attention if it comes up again after a successful installation…

    Reply
  199. Martin,

    It really is a nice solution, if I might offer some constructive comments?

    Having the “Dismiss” button always enabled if the “Snooze” button is enabled I think is a mistake. Imagine you want to notify the user every 24 hours, you need to run the PowerShell script every 24 hours but you don’t know if it’s already running and the user chose “Snooze” or if it’s no longer active and they chose “Dismiss”. It would be better to not run a second instance of the script and to deal with it now, removing the “Dismiss” button and only leaving the “Run” or “Snooze” button at least won’t run multiple instances and yo can be certain it’s still running.

    I also do understand you intend systems targeted with the script to drop out of the target Collection if the software condition is no longer valid but you have to run inventory aggressively for that (we run daily but default is weekly). It really would be better to check the install status and not display the script if the job was run with a success status returned…

    Regards,

    Jack

    Reply
  200. Hi again Martin,

    Do you know why the toast is still showing up during the lockscreen?

    We have disabled it through GPO and I have checked the registry key has been created and set it to 1

    \HKEY_CURRENT_USER\SOFTWARE\Policies\Microsoft\Windows\CurrentVersion\PushNotifications

    NoToastApplicationNotificationOnLockScreen

    What else can we check? any thoughts?

    Regards

    Reply
  201. Hello Martin,

    Thank you for the great work here. I hope you can help us out.

    In my organization we run a Windows 10 upgrade Task Sequence.
    This allows us to keep/implement customizations.

    I am having trouble understanding and I hope you can help out. From reading the instructions I gather…

    We create a standard package in SCCM with command line:

    Command line example: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle
    Hidden -File .\New-ToastNotification.ps1 -Config \\YourUNCPath\ToastNotificationScript\Configs\config-toast-osupgrade.xml

    From config-toast-osupgrade.xml we build up our upgrade parameters.

    1. What is “Target OS Mean”? Is this the users O/S version we want to upgrade from?
    Or
    Is this the O/S we want to upgrade to. (In our case 20H2).

    2. You have entered package ID “KR100907″…. Here we would enter our upgrade
    Task Sequence package ID I assume for the 20H2 upgrade.

    3. We deploy both the upgrade TS and the new Toast Package to the appropriate
    device collection.
    – The end user gets the toast notification the next time SCCM checks in?

    4. Can we place a URL into the “Body Text” pointing to instructions? (Will the URL
    function from inside the toast notification?)

    Thank you Martin. MS needs to put these features into the core of SCCM. User communication like this is pure gold.

    Tony.

    Reply
    • 1) TargetOS is the OS build you plan on moving to (hence target), so in your case that would be the build number of 20H2 (19042).
      2) Correct, the packageid of the task sequence
      3) Correct, remember to deploy the task sequence with ‘Allow user to run the TS regardless of assignments’ enabled if having a required deployment. The TS needs to visible in the SC
      4) No URLs in the body text I’m afraid. This is not something the framework in Windows can do.

      Let me know how you move on 🙂

      Reply
  202. Hello!

    The greeting based on time of the day is not working correctly here.
    I get Good Evening in the Afthernoon.

    Is it possibel to adjust this ?

    regards Chantal

    Reply
    • Yeah, check line 1744 in the script. Perhaps something with your language settings is a conflict here. I’m assuming 24-clock, which I know might not suit everyone 🙂

      Reply
    • Search for greeting. I guess the linenumber depends on which version you are using. If you search for greeting, you will find the section where the personal greeting is made up based on the time of day of a 24-clock. I might need to adjust this make it aware of local regional settings on the computer.

      Reply
  203. Hi Martin

    Just found your script and it’s brilliant!
    We are using it in only a Powershell use case with PDQ Deploy, and was wondering if there is anything stopping images being rendered from a UNC path rather than an http path as in the documentation? I’m away from my work now so will retest on Monday in case I’ve made an error, but thought I’d ask just in case.

    Reply
    • Yeah, images on an UNC location is not supported. This is determined by the framework itself and not the script. So either local images next to the script (images folder) or images hosted via an http(s) protocol 🙂

      Reply
  204. This is a brilliant function to have. Using it as general notifications in TS works a charm.

    However, I’m having a challenge with the SCCM deployed package. Notify for password change. In my test, I changed the period to 30 days. I received the notification once, clicked dismissed and it won’t appear again. The task is set to always rerun with an hourly run schedule.

    I’m unable to find the log file as referred to in the guide.

    Reply
    • Are you running the program in the user’s context? This is configured on the environment tab of the program (run with user’s rights and only when a user is logged on). If so, the log file should be in appdata\toastnotificationscript. Are your password actually expiring within those 30 days?

      Reply
      • Yes, it’s expiring in 30 days. It showed the notification once.

        Yes “Run with user’s rights” is ticked.

        I made a change on the schedule now, looks like it is working, I will report back.

        Should I use “Persist content in client cache”? Sound like a good option for this kind of deployment, especially if nothing in the notification is changing that often if it does. I’m referring to the Password Expiry notification only.

        Reply
        • > “I made a change on the schedule now, looks like it is working, I will report back.”

          Sounds great, let me know if any issues.

          If you have a weekly reoccurring schedule, using persist content in client cache shouldn’t do much. Configmgr will never reach a point where the content is cleaned up. 🙂

          Reply
  205. Hi Martin,

    Quick question: I created this package to run as user context but I got this error from execmgr.log

    Unable to access network resource [C:\WINDOWS\ccmcache\4g] with currently known credentials.

    we have the default permissions applied in ccmcache, so the user cannot navigate there… but I thought the Software Center could run it as user context. Any thoughts? I’m missing something?

    Thank you

    Reply
    • Yes, you will need to modify this directly in the function for TestingPendingReboot in the beginning of the script.

      Reply
  206. Hi Martin, thank you very much for this.
    One thing I noticed is that I can’t seem to remove the Restart Now button. I have set the ActionButton1 button to False in the xml file and even removed the command from the Action1 which would trigger the reboot. I have already removed the Action2 button if that matters. I basically just want a Dismiss button, which I have showing. Thanks.

    Reply
    • Hah, oddly enough, I had so many test notifications queued up that I didn’t see the new ones until a few minutes later. False alarm. 😉 Thanks again for this.

      Reply
  207. Hi Martin,

    Just wondering if there is something I’m doing wrong. When I’m running a package install from the Toast Notification it will redirect it to Software Center and will open the Operating Systems but, instead or the package itself or the Installation Status tab.
    Any idea why this is happening?

    Reply
    • Yeah, with a package I’m assuming the package id of a task sequence and referring to using this with an upgrade of Windows. I see how that’s weird when using it for something else. You can correct this yourself, by removing one line in the new-toastnotification script, in the region where the custom scripts are being created.

      Reply
      • So I can’t have both working in the same time? I have to choose one option?
        Will be much appreciated you can give me more details?

        Reply
  208. Is it possible to use the OSupgrade option if you only use powershell for this? How would I go about doing that? Its implied that a task sequence needs to be used for the deployment of the OS upgrade.

    Reply
  209. Hi Martin, this was so helpful thankyou, I have one issue I need helping with if possible?

    Deploying this for an OS upgrade as a package with one action button the snooze button and dismiss. Ideally we wouldnt want the dismiss button just the action and snooze but you cant if you have the snooze. The issue we have is once the user presses dismiss the toast wont appear again, is there anyway to get around this?

    Thanks,

    Aidan

    Reply
    • If you run this with configmgr, your re-run schedule would be responsible of showing the toast notification again, and again… and every so often you want it. Ideally, the re-run schedule is what you should rely on, so I recommend not using the snooze option, but rely on how often you run the script.

      Reply
  210. Getting error ” failed with exit code 4294770688 ” when i try run it on the local machine. I followed the same steps to call the xml from shared location. Any advise

    Reply
  211. Any way to make this run under a task sequence? Not in WinPE but in Windows 10. Cause under task sequence user deployments are not allowed. I used psappdeploy to make it run successfully but it shows the powershell window for a few seconds. And running powershell silently will also hide the toast notification.

    Reply
    • I’m sure that’s possible. I actually have an unreleased version of the toast script lying around, which is capable of running coming from system context. Let me look into finishing that up. 🙂

      Reply
    • See my latest blog post. I just released that version, which is able to run the script coming from a task sequence 🙂

      Reply
  212. Hi Martin,

    Thanks for adding “prevention of having multiple toast notifications”, just got some complains from users receiving 3-4 in the same time :).

    Not sure if the stuff you are doing are the same, but before using your solution, I use to run below code at the beginning of every Toast Notification scripts to clear the “toast history”.
    Can you confirm pretty much same will happen using your newly added option?

    # Load required namespaces

    $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]

    $null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]

    # Register the AppID in the registry for use with the Action Center, without this, the toast messages for PowerShell could be turned off by the user.

    $app = ‘{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe’

    $AppID = “{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe”

    $RegPath = ‘HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings’

    $null = New-Item -Path “$RegPath\$AppId” -Force

    $null = New-ItemProperty -Path “$RegPath\$AppId” -Name ‘ShowInActionCenter’ -Value 1 -PropertyType ‘DWORD’

    [windows.ui.notifications.toastNOtificationManager]::History.Clear($App)

    Reply
    • So I basically had this:# Remove Toast Notification History for when using Powershell as application for the toast

      Write-Log ” —- Remove Toast Notification History for when using Powershell as application for the toast — ”
      # Load required namespaces

      $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]

      $null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]

      # Register the AppID in the registry for use with the Action Center, without this, the toast messages for PowerShell could be turned off by the user.

      $app = ‘{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe’

      $AppID = “{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\\WindowsPowerShell\\v1.0\\powershell.exe”

      $RegPath = ‘HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings’

      $null = New-Item -Path “$RegPath\$AppId” -Force

      $null = New-ItemProperty -Path “$RegPath\$AppId” -Name ‘ShowInActionCenter’ -Value 1 -PropertyType ‘DWORD’

      [windows.ui.notifications.toastNOtificationManager]::History.Clear($App)

      # Remove Toast Notification History for when using Software Center as application for the toast

      Write-Log ” —- Remove Toast Notification History for when using Software Center as application for the toast — ”

      # Load required namespaces

      $null = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]

      $null = [Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime]

      # Register the AppID in the registry for use with the Action Center, without this, the toast messages for PowerShell could be turned off by the user.

      $app = “Microsoft.SoftwareCenter.DesktopToasts”

      $AppID = “Microsoft.SoftwareCenter.DesktopToasts”

      $RegPath = ‘HKCU:\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings’

      $null = New-Item -Path “$RegPath\$AppId” -Force

      $null = New-ItemProperty -Path “$RegPath\$AppId” -Name ‘ShowInActionCenter’ -Value 1 -PropertyType ‘DWORD’

      [windows.ui.notifications.toastNOtificationManager]::History.Clear($App)

      Reply
      • Not entirely the same Oleg. You are clearing the toasts which are stored in the OS, I prevent the catch up mechanic in ConfigMgr to be the cause of multiple toast notifications. Lets say you run the script everyday for a week, but a device is offline for 2. Those 2 days of being offline will cause the toast notifications to be displayed once the devices comes online. This can be prevented with the new option 🙂

        Reply
  213. i used this toast for our 2004 upgrade worked like a charm. modifying it to work for 20h2. i changed the xml to the new TS id and the target os to 19042. running the powershell script manually works fine but when running through an SCCM program i get an exit code 1 and it fails. i didnt see this with my previous package and they are set up the same way.

    Reply
    • Are you sure that you have configured the program to run in the user’s context? It’s on the environment tab.

      Reply
  214. Hi Martin,
    Many thanks for sharing this amazing script !
    I plan to use it in config manager to remind users for Office ProPlus Upgrade.
    Is there any way to exit and not display the toast notification if ApplicationID is already installed in Software ?
    I would like to run the script as a package with custom interval but not if users have already installed the application.
    Marc

    Reply
    • Hi Marc, the only option you currently have in order to achieve this, is to manage your collections tightly. Depending on how often you rerun the toast script, you will have to run hardware inventory accordingly, so devices can move in/out of the collection where you are deploying the toast script.

      Reply
  215. Hi Martin,

    Excellent work. This will provide exactly what my organization is looking for. Is there anything you’re aware of that would allow body text to be forced to the next line, rather than a continuation on the current line?

    Thanks.

    Reply
  216. Hi Martin,
    Like everyone here has already said, great script, it saved many hours at least for me being able to use your script. The only caveat for me is if people snooze (users find it useful) but before the snooze time is up and users reboot, the notification will show up regardless when the snooze time is finished, although the user has already rebooted. Is there a chance to include to clear snoozes if the user reboots or do you know from top of your head what parameter is needed?

    Thanks dude

    Reply
  217. Can this be configured to show toasts when Windows Update requires reboots?
    Can I configure countdowns?
    Windows own notices aren’t good enough for me
    (sorry if I ask and the Q is already asked but you have so many comments here)

    Reply
  218. Hi.

    Thank you for this. I am trying to setup the Reboot Script but i get the below error. Im not sure what Im missing

    Get-Service : Cannot find any service with service name ‘ccmexec’.
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1736 char:42
    + … (($SCAppStatus -eq “True”) -AND (-NOT(Get-Service -Name ccmexec))) {
    + ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (ccmexec:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

    Write-Log : Error. Using Software Center app for the notification requires the ConfigMgr client installed
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1737 char:5
    + Write-Log -Level Error -Message “Error. Using Software Center app …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Write-Log : Error. Please install the ConfigMgr client or use Powershell as app doing the notification
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1738 char:5
    + Write-Log -Level Error -Message “Error. Please install the Config …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Reply
  219. Thank you for this. I am trying to setup the Reboot Script but i get the below error. Im not sure what Im missing

    Get-Service : Cannot find any service with service name ‘ccmexec’.
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1736 char:42
    + … (($SCAppStatus -eq “True”) -AND (-NOT(Get-Service -Name ccmexec))) {
    + ~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : ObjectNotFound: (ccmexec:String) [Get-Service], ServiceCommandException
    + FullyQualifiedErrorId : NoServiceFoundForGivenName,Microsoft.PowerShell.Commands.GetServiceCommand

    Write-Log : Error. Using Software Center app for the notification requires the ConfigMgr client installed
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1737 char:5
    + Write-Log -Level Error -Message “Error. Using Software Center app …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Write-Log : Error. Please install the ConfigMgr client or use Powershell as app doing the notification
    At C:\Source\ToastNotificationScript2.2.0\New-ToastNotification.ps1:1738 char:5
    + Write-Log -Level Error -Message “Error. Please install the Config …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Reply
    • According to that logging information, you are running the script without ConfigMgr and you should switch to using powershell as the app doing the notification.

      Reply
  220. Hi,
    Thank a lot for this!!!

    Is it possible to remove the app name running the toast msg (Windows PowerShell/Software Center) or is this mandatory to have?

    SF

    Reply
  221. Just did a test run only running the ps1 so that it would default to the only xml I had fiddled with. It showed a powershell window for a moment, then nothing else, and no log files within appdata. Any ideas?

    Reply
    • I read the PDF and figured out how to properly make the command line. Got a couple issues to iron out, but you can disregard that one.

      Reply
  222. Okay I can’t quite get it. I tried googling windows protocols, and tried putting “C:\Windows\CCM\ClientUX\SCClient.exe” directly, all I want is a button to open software center, but it won’t do it. What is the action button I need?

    Thanks

    Reply
    • The toast notification can only handle protocol based actions, thus if you need to open software center you would explicitly call something like softwarecenter:page=AvailableSoftware. Try it out in Run. if it works from Run, it works from the toast notification as well. 🙂

      Reply
  223. Hey everything working well but i cant seem to get the images working at all cant see anything in the log file relating to the images but it just shows all the text fine and launches software centre and kicks of the install for an available application however its just not displaying the images any ideas?

    Reply
    • are you using any custom images? Are you having too much text? Try to cut down on the amount of characters and use the built in images.

      Reply
  224. Hi,

    ready for testing that !!

    here is the french translation, if you want include it:

    Votre ordinateur doit redémarrer car il a dépassé le temps de fonctionnement maximal défini.
    Raison: un redémarrage en attente a été trouvé dans le registre ou WMI.
    Votre mot de passe va expiré le:
    Dites. Votre ordinateur a besoin de redémarrer. Faites le maintenant.
    Installer maintenant
    En savoir plus
    Rejeter
    Veille
    https://www.imab.dk
    Le support vous rappelle gentiment…
    Mise à jour de Windows 10 disponible!
    Il y a une nouvelle mise à jour de Windows 10 de disponible. Installez la vous même, sinon nous le ferrons pour vous
    Pas d’inquiétude! Vous receverez un nombre suffisant de rappels avant que toute action ne soit prise automatiquement.
    Cliquez sur veille pour un rappel à nouveau dans:
    Votre date limite est:
    Bonjour
    Bonjour
    Bonsoir
    Minutes
    Heure
    Heures
    Ordinateur allumé depuis:
    jours

    Reply
  225. Hi Martin,

    Do you know if it’s possible to bold or underline the test in the Toast Notification? Example the text under ” “?

    Reply
  226. Hey Martin, I just downloaded and ran your script without changing anything but the toast notification that is popping up is a generic Windows PowerShell new notification. Out of the box, using the default config-toast XML file. Below is the console messages omitting some company info.

    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Script is initially running in USER context
    VERBOSE: No config file set as parameter. Using local config file
    VERBOSE: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    VERBOSE: Successfully loaded \\****\****\****\_Nathan\Toast Application\Toast Reboot 1.1\Original\config-toast.xml
    VERBOSE: Loading xml content from \\****\****\****\_Nathan\Toast Application\Toast Reboot 1.1\Original\config-toast.xml into variables
    VERBOSE: Successfully loaded xml content from \\****\****\****\_Nathan\Toast Application\Toast Reboot 1.1\Original\config-toast.xml
    VERBOSE: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    VERBOSE: Script version: 2.2.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    VERBOSE: Running Get-DeviceUptime function
    VERBOSE: PendingRebootUptime set to True. Checking for device uptime. Current uptime is: 0 days
    VERBOSE: Greeting with given name selected. Replacing HeaderText
    VERBOSE: Greeting with Good afternoon
    VERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory: Nathan
    VERBOSE: Creating the xml for no action button
    VERBOSE: Creating the xml for displaying the second action button: actionbutton2
    WARNING: This will always enable both action buttons and the dismiss button
    WARNING: Replacing any previous formatting of the toast xml
    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: Confirmed USER context before displaying toast
    VERBOSE: All good. Toast notification was displayed

    Reply
  227. Hi Martin, I just downloaded the most recent version of this app and am having some troubles. Fresh from install without changing any config or powershell files, I ran it and it displays a powershell generic toast notification. Do you have a clue as to why its not performing as expected?

    Reply
  228. Hi Martin,

    Not sure if you are interested, but I’ve modified a bit the config file and the script to be able to use it for Windows Updates and O365 install. This requires to update monthly the XML with latest KBs and Office version.
    Pretty sure it’s not the most optimal way to do this but it work fine for me 🙂

    XML update:








    Script update:

    # Get Office 365 Version
    $InstalledO365version = (Get-ItemProperty HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\* | ? {$_.DisplayName -like “Microsoft 365 Apps for enterprise – en-us*”}).DisplayVersion

    $RunWindowsUpdates = $Xml.Configuration.Feature | Where-Object {$_.Name -like ‘RunWindowsUpdates’} | Select-Object -ExpandProperty ‘Enabled’

    $TargetKB01 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB01’} | Select-Object -ExpandProperty ‘KBNumber’
    $TargetKB02 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB02’} | Select-Object -ExpandProperty ‘KBNumber’
    $TargetKB03 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB03’} | Select-Object -ExpandProperty ‘KBNumber’
    $TargetKB04 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB04’} | Select-Object -ExpandProperty ‘KBNumber’
    $TargetKB05 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB05’} | Select-Object -ExpandProperty ‘KBNumber’
    $TargetKB06 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘TargetKB06’} | Select-Object -ExpandProperty ‘KBNumber’
    $Office365 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘Office365’} | Select-Object -ExpandProperty ‘O365Version’

    # Toast used for Windows Updates. Checking Installed KBs. No need to display toast, if the KB is already Installed

    $KBArray = @()
    If ($TargetKB01 -ne $Null) {$KBArray += “$TargetKB01”}
    If ($TargetKB02 -ne $Null) {$KBArray += “$TargetKB02”}
    If ($TargetKB03 -ne $Null) {$KBArray += “$TargetKB03”}
    If ($TargetKB04 -ne $Null) {$KBArray += “$TargetKB04”}
    If ($TargetKB05 -ne $Null) {$KBArray += “$TargetKB05”}
    If ($TargetKB06 -ne $Null) {$KBArray += “$TargetKB06”}
    $KBsNumber = $null
    $KBToInstallArray = @()
    $KBInstalledArray = @()
    foreach ($TargetKB in $KBArray) {

    if (!(Get-HotFix -Id $TargetKB -ErrorAction SilentlyContinue )) {

    $KBToInstallArray += “$TargetKB”
    $KBsNumber = $KBsNumber + 1

    }
    Else { $KBInstalledArray += “$TargetKB”}
    }

    if (($RunWindowsUpdates -eq “True”) -AND (($KBsNumber -ne $null) -OR !($InstalledO365version -ge $Office365))) {

    If ($KBsNumber -NE $null) {Write-Log -Level Warn -Message “$KBToInstallArray – Not Installed”}

    If (!($InstalledO365version -ge $Office365)) { Write-Log -Message “Office 365 Latest version $Office365 – Not Installed” }

    Write-Log -Message “Toast notification is used in regards to Windows Updates”

    Display-ToastNotification
    # Stopping script. No need to accidently run further toasts
    break
    }
    else {
    Write-Log -Level Warn -Message “Conditions for displaying toast notifications for RunWindowsUpdates are not fulfilled.”
    Write-Log -Level Info -Message “$KBInstalledArray – are Installed”
    Write-Log -Message “Latest Office 365 version – $InstalledO365version Installed !!!”
    }

    Would be great if you can add something similar to your next release 🙂 . Thanks.

    Reply
  229. Removing

    Feature Name=”RunWindowsUpdates” Enabled=”True” / !– Enables he toast to run Windows Updates —
    Option Name=”TargetKB01″ KBNumber=”KB4565554″ / !– The actual KB Id number we need to install.–
    Option Name=”TargetKB02″ KBNumber=”KB4497165″ / !– The actual KB Id number we need to install. —
    Option Name=”TargetKB03″ KBNumber=”KB4517245″ / !– The actual KB Id number we need to install.–
    Option Name=”TargetKB04″ KBNumber=”KB4517245″ / !– The actual KB Id number we need to install.–
    Option Name=”TargetKB05″ KBNumber=”” / !– The actual KB Id number we need to install.–
    Option Name=”TargetKB06″ KBNumber=”” / !– The actual KB Id number we need to install. —
    Option Name=”Office365″ O365Version=”16.0.14131.20320″ / !– Office 365 Build Version to Install. —

    Reply
  230. Hi, is it possible to force a restart using this script, say after the deadline is reached for software updates

    Reply
  231. Hello, anyone successfully deployed this via Intune as a PS Script?
    I created 1 PS script to download the images, xml and toast notification ps from a blob, then executed the ps but it does not appear. Any suggestions besides creating a win32app? Thanks

    Reply
  232. Hello,
    Is there anyway I can modify the script to have 2 action buttons and that’s it? I don’t want to include a dismiss button as I feel like it’ll get confusing. I added this script to another script we have that initiates a reboot to happen in 2 minutes. My intention is to have one button say “Reboot” which reboots the machine immediately and the other button to say “Abort Reboot” which will cancel the reboot that will be happening in 2 minutes from when the notification is shown. I’ve already modified the script to have a custom script and protocol called “ToastAbort” and it works perfectly. I’m just hoping I can create a notification to have those 2 buttons as options and that’s it. Whenever I try to do that, it still creates the dismiss button regardless if put False for it in the configuration XML. Hopefully this all makes sense. Any help would be greatly appreciated.

    Reply
  233. Hello,

    I believe I have everything set up correctly but I get this in the logs and the toast never displays.

    2021-08-24 11:19:02 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2021-08-24 11:19:02 INFO: Something is not right about toast notifications in Windows. The script will run, but toasts might not be displayed
    2021-08-24 11:19:02 INFO: No config file set as parameter. Using local config file
    2021-08-24 11:19:02 INFO: Successfully loaded C:\WINDOWS\ccmcache\z\config-toast.xml
    2021-08-24 11:19:02 INFO: Loading xml content from C:\WINDOWS\ccmcache\z\config-toast.xml into variables
    2021-08-24 11:19:02 INFO: Successfully loaded xml content from C:\WINDOWS\ccmcache\z\config-toast.xml
    2021-08-24 11:19:02 INFO: Creating the xml for no dismiss button
    2021-08-24 11:19:02 INFO: Creating the xml for snooze button
    2021-08-24 11:19:02 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2021-08-24 11:19:02 INFO: All good. Displaying the toast notification
    2021-08-24 11:19:02 WARNING: Something went wrong when displaying the toast notification
    2021-08-24 11:19:02 WARNING: Make sure the script is running as the logged on user

    I’m logged in as a regular user when the script runs but I have the program to run with admin rights. I also disabled the step in the xml to get greet given name but no luck.

    Reply
  234. Hello Martin,

    how would I achieve a force reboot after say 3 snooze action, is there a way to write the snooze action to the registry and at check it to force the reboot.

    Reply
  235. Hi.
    Just downloaded this to try it as I’ve a problem with another toast script not displaying the popup. Sadly yours doesn’t either. The log file finishes with
    INFO: All good. Toast notification was displayed
    except that it wasn’t. Presume from what I’ve read that it shouldn’t need admin rights or anything special? Any suggestion as to where to look?
    Thanks

    Reply
  236. Hi Martin!
    First of all I would like to say this is great work!
    I am wondering if there is a way to have an action button launch an executable on the system drive? I am looking to use it to start BitLocker Drive Encryption by launching MBAMClientUI.exe.

    Reply
      • Thanks Martin!
        I got the custom protocol working.
        I am however running into another issue. I am trying to run this as a remediation script in Configuration Manager CI. I have it setup to run using the logged on user credentials and it is using the config file stored in Azure blob storage as you showed. The problem is the script is not displaying and the log shows the following:
        2021-11-03 11:00:14 INFO: Script is initially running in USER context
        2021-11-03 11:00:14 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
        2021-11-03 11:00:14 INFO: Successfully loaded 1
        2021-11-03 11:00:14 INFO: Toast notification is not enabled. Please check 1 file
        I have double checked the path to the script and it appears correct. I’m not sure where “1” is coming from. Any idea?

        Reply
        • Looks like it’s not loading the config.xml properly. How are you referencing the config file? If hosted online, the log file should indicate that with a ONLINE tag.

          Reply
          • Here is the beginning of the script. I copied this locally into PS ISE and it does display the toast notification when run this way. Does something have to be changed for it to run from CM config item remediation script?

            [CmdletBinding()]
            param(
            [Parameter(HelpMessage=’Path to XML Configuration File’)]
            [string]$Config = “https://123configfiles.blob.core.windows.net/toastnotification/config-toast-bl.xml”
            )

            #region Functions
            # Create Write-Log function
            function Write-Log() {

  237. I have added my package on SCCM and setup my upgrade Task Sequence to upgrade my Windows 10 machines to 21H1 (tageting my out of support machines fo rnow)

    I just wnated to test the Toast to see what it would look like. I tried running my script and the notification does not display. I double checked the registry and the notifications are enabled. Any thoughts and assistance please? Below is the export from the log/PS command

    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Toast notifications are enabled in Windows
    VERBOSE: No config file set as parameter. Using local config file
    VERBOSE: Successfully loaded C:\XXX\Toast\config-toast.xml
    VERBOSE: Loading xml content from C:\XXX\Toast\config-toast.xml into variables
    VERBOSE: Successfully loaded xml content from C:\XXX\Toast\config-toast.xml
    VERBOSE: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    VERBOSE: Running Write-PackageIDRegistry function
    VERBOSE: PackageID: XXX was found in WMI as deployed to the client
    VERBOSE: Writing the PackageID to registry
    VERBOSE: Greeting with given name selected. Replacing HeaderText
    VERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory
    VERBOSE: Creating the xml for displaying both action button and dismiss button
    VERBOSE: Creating the xml for snooze button
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    WARNING: Conditions for displaying default toast notification are not fulfilled

    Reply
  238. Hi Martin,

    Awesome job! really Cool! one quick question, Our AAD devices are unable to get to on-prem domain to get the password expiration notification for the user when not connected to the VPN or corporate network. Which is by design, but there should be a way to search for the azure AD acc instead of looking for the on-prem domain?

    Reply
  239. Hi Martin,

    I tried have my Windows 20H2 Task Sequence setup in ConfigMgr, and deployed it to my collection. I also created the package for the toast notification and set that to run first for my TS. I tested running the script, but the notification does not display. I also I tested manually, and it still does not display. I used both UseSoftwareCenterApp nd Powershell as Enabled=False and True as well as, but it still does not display. I keep getting the message that Conditions for displaying toast notifications for UpgradeOS are not fulfilled

    below is the the xml I have for



































    Your computer is required to restart due to having exceeded the maximum allowed uptime.
    Reason: Pending reboots was found in registry or WMI.
    Your password will expire on:
    Hey you – wake up. Your computer needs to restart. Do it now.
    Restart now
    Learn More
    Dismiss
    Snooze
    http://www.massmart.co.za
    Massmart IT kindly reminds you…
    A Windows 10 upgrade available!
    There’s a new Windows upgrade available. Do yourself a favor and install it yourself…. or we will do it for you 😉
    Don’t worry! You will receive an adequate amount of reminders before any actions are taken automatically.
    Click snooze to be reminded again in:
    Your deadline is:
    Good morning
    Good afternoon
    Good evening
    Minutes
    Hour
    Hours
    Computer uptime:
    days

    Below is the log

    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Script is initially running in USER context
    VERBOSE: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    VERBOSE: Successfully loaded .\config-toast.xml
    VERBOSE: Loading xml content from .\config-toast.xml into variables
    VERBOSE: Successfully loaded xml content from .\config-toast.xml
    VERBOSE: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    VERBOSE: Script version: 2.2.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and
    protocols
    VERBOSE: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    VERBOSE: Running Write-PackageIDRegistry function
    VERBOSE: PackageID: PT100186 was found in WMI as deployed to the client
    VERBOSE: Writing the PackageID to registry
    VERBOSE: Greeting with given name selected. Replacing HeaderText
    VERBOSE: Greeting with Good morning
    VERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory: Kesh
    VERBOSE: Creating the xml for no action button
    VERBOSE: Creating the xml for displaying the second action button: actionbutton2
    WARNING: This will always enable both action buttons and the dismiss button
    WARNING: Replacing any previous formatting of the toast xml
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    WARNING: Conditions for displaying default toast notification are not fulfilled

    Reply
    • Take a look at the TargetOS option in the config.xml This should match a OS build which is higher than the one you’re currently running.

      Reply
  240. For some reason I keep getting two errors below

    Failed to check enrollment url, 0x00000001: execmgr 11/17/2021 2:15:00 PM 11304 (0x2C28)
    Script for Package:SMC00603, Program: Toast OS Upgrade Notification failed with exit code 1 execmgr 11/17/2021 2:14:02 PM 17240 (0x4358)

    I followed the instructions but cant seem to go around this. Any help is appreciated.

    Reply
    • A log file should be generated for you in appdata\toastnotificationscript which will tell you more about the error. I exit the script with code 1 several places, if things are not working as expected.

      Reply
  241. Hi Martin,
    In our organization the workstations are hybrid AAD joined. The users are working remotely and VPN in to access on-prem resources. I’ve noticed the toast notification script only displays the user’s name when the user has the workstations connected to the VPN. Is there a method to get it to work over the Internet with AAD?

    Reply
    • Hey and weird. The script is designed to pick up the given name from registry if no AD is available. The toastnotificationscript log will also tell you when that happens. Can you provide a log file from that specific scenario? 🙂

      Reply
      • Hi Martin,

        Here is the output from the log.
        2021-11-17 10:20:30 INFO: Running Get-GivenName function
        2021-11-17 10:20:30 ERROR: Current security context is not associated with an Active Directory domain or forest.
        2021-11-17 10:20:30 INFO: Given name not found in AD or no local AD is available. Continuing looking for given name elsewhere
        2021-11-17 10:20:30 INFO: Given name not found in registry. Using nothing as placeholder

        Reply
        • Looks like the registry key I use to find the given name, does not exist on your devices. If you have given name registered elsewhere in registry, you can update the Get-GivenName function in the script to match this. 🙂

          Reply
          • Okay I see what it is doing. I can manually see the LastLoggedOnDisplayName registry entry without admin rights, so that should be working okay. The values in our organization are in format “lastname, firstname”. Could the comma in this value be causing a problem? If so, do you have any ideas how I could modify the script?

          • I’d extract the Get-GivenName out of the script and run that separately. What result do you get?

          • Hi Martin,
            It seems it is displaying lastname,(comma). It doesn’t display the first name. Any idea how to have it display the first name as well?

          • Right, that would require a slight adjustment of the Get-GivenName function to pick the first name in reverse order 🙂

  242. Anyone know how to get custom protocols ? I notice the screenshot has for ADPasswordExpiration has settings button but not sure how to get this or change it

    Reply
    • I’m not sure I understand your question I’m afraid. What do you need to change? The ADPasswordExpiration is not a custom protocol, but something I built into the script and therefore has settings in config.xml 🙂

      Reply
  243. https://www.imab.dk/wp-content/uploads/2019/09/2019-09-24-16_36_52-Window.png

    I cannot find the settings to configure the ActionButton1 to display the option in the image above or to provide the users an option to click on the button and go to change password screen (How to create Custom Scripts/Protocols like ToastReboot if i want to change the display on ActionButton1 or ActionButton2

    The config-toast-adpwexpiration.xml settings seem to be an copy of the config-toast, I was thinking these were filled out to be based on your examples images

    Reply
    • If you put following in Run “ms-settings:signinoptions:” it will take you to a place in settings, where the user is able to reset their password. What’s the button is called, is defined in the config.xml. I believe the various .xml files I include is different from each other on this part. You can reach out to my email at mab@imab.dk if things are still giving you troubles 🙂

      Reply
  244. Question

    How can I get this to execute a large group of machines remotely. When I try to execute this script on remote systems it appears to just run on my system multiple times. Can someone tell me what I could be doing wrong. How can I get this run on remote systems under the logged in users session.

    Reply
      • We are but I do not have access to it to implement this script. I was wondering if there was a way to run it from powershell.

        Reply
        • I haven’t tested remote PowerShell and the script in any way I’m afraid. Everything is designed around ConfigMgr or Intune and Group Policy as a last resort.

          Reply
  245. Hi Martin – thank you for this great resource! We are using it to manage our latest feature update, and my boss is so excited by the results he asked me if we can use it every month for regular software updates in SCCM. Is that possible?

    Reply
    • Hi Mike, I’m so glad to hear that. Yes, you can specify a single KB in the config.xml Let’s say the monthly CU for Windows 10, and it should work similar to feature updates. I haven’t worked specifically with that scenario though, so you will have to give it a try to see if it process is acceptable.

      Reply
  246. Hi Martin! I have built custom windows update, alert and reboot procedure based on your scripts. Great work!

    In my case there were issues when files of script did not copy to clients computers via group policy yet, and scheduled task starting script shows alert from windows script host like “script not found”

    For me it was solved by adding /b to arguments of wscript.exe in scheduled task:
    wscript.exe /b “C:\ProgramData\ToastNotificationScript\PendingReboot\Hidden.vbs” “C:\ProgramData\ToastNotificationScript\PendingReboot\RunToastHidden.cmd”

    Hope this will be useful for your followers, and maybe you add this hack to pdf manual distributed with script

    Reply
  247. Hi Martin,
    Thanks for this it is amazing!

    I have a script that runs from intune as a script to rename the device, i am not sure what i need to add to the script to get it to force a toast reboot is required ?

    any help apreciated.

    Reply
  248. Hi Martin
    Thank you for this Great script! we are using this as feature upgrade reminder to users in our org.
    One issue i am enountering is when using URL that has special characters like “=” in its path for value of Action2 button in the xml file.
    The URL points to a service now KB article which is in format
    “https://comapnyname.service-now.com/esp?Id=1403993”

    when checking logs, i get this:
    “” to type “System.Xml.XmlDocument”. Error: “‘=’ is an unexpected token. The expected token is ‘;’. Line 34, position 91.””

    any suggestions?
    I am using tinyurl short url for now as workaround but it would be nice if i can use the direct link

    Thanks

    Reply
  249. I have been using previous versions of this product with great success, an upgrade and survey prompt for Windows Features updates. One issue encountered was that users could simply set their Focus Assist settings to Priority-/Alarms only, with no programmatic way to register an exception. From reading 2.3.0 notes has this been specifically solved?

    Reply
    • Right. You can even configure the toast via the config.xml to be an alarm. Change the type from reminder to alarm. Also, using the new feature mentioned in 2.3.0 will indefinitely prevent the user from disabling the notifications 🙂

      Reply
      • Excellent! This toolset is great for solving the issue of communicating to the logged on users of hotdesk/multi user devices that are targeted for upgrade, where user based comms does not work, and stats likely primary user are not reliable.

        I did change a few things for our purposes: adding user button press logging to the dynamically generated ToastRunPackageID script, for when users say they did not press it but actually did.

        Write-EventLog -LogName “Application” -Source “WSH” -EventID 54 -EntryType Information -Message “Windows 10 20H2 Upgrade Toast Notification: User clicked on Upgrade button.”

        And if multiple instances of ToastNotificationScript version are installed, then there can be user protocolhandler conflicts, so I modified: HKCU:\SOFTWARE\ToastNotificationScript -> UpgradeToastNotificationScript, and then was sure to delete these HKCU keys on uninstall, as I will be using this for the next Windows Feature rollout at the same org.

        Reply
  250. Greetings
    I would like to express my gratitude to the author thank you for the work done
    But I had a small problem when implementing this product.

    I made a group policy to copy files and add tasks according to the instructions, but the alert works every time the user fully logs in or reboots.
    Namely, the user is shown a window asking to reboot the system, he performs it, and when he logs in, he again sees information about the need to reboot.
    It seems that the parameter does not apply
    Please tell me how to fix the error and so that the information window is displayed only if the MaxUptimeDays parameter is exceeded

    Reply
    • Can you paste the content of the log file, for when this is happening? The log is located in appdata\ToastNotificationScript. Also, what value have you configured in the MaxUptimeDays option?

      Reply
  251. Log After Reboot

    2022-01-14 12:00:45 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-01-14 12:00:45 INFO: Script is initially running in USER context
    2022-01-14 12:00:45 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2022-01-14 12:00:45 INFO: Successfully loaded C:\ProgramData\ToastNotificationScript\PendingReboot\config-toast.xml
    2022-01-14 12:00:45 INFO: Loading xml content from C:\ProgramData\ToastNotificationScript\PendingReboot\config-toast.xml into variables
    2022-01-14 12:00:48 INFO: Successfully loaded xml content from C:\ProgramData\ToastNotificationScript\PendingReboot\config-toast.xml
    2022-01-14 12:00:48 INFO: Running Register-NotificationApp function
    2022-01-14 12:00:48 INFO: Created registry entries for custom notification app: iMAB.DK NOTIFICATIONS
    2022-01-14 12:00:48 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2022-01-14 12:00:48 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2022-01-14 12:00:48 INFO: Running Get-DeviceUptime function
    2022-01-14 12:00:50 INFO: PendingRebootUptime set to True. Checking for device uptime. Current uptime is: 0 days
    2022-01-14 12:00:50 INFO: Greeting with given name selected. Replacing HeaderText
    2022-01-14 12:00:50 INFO: Greeting with Good afternoon
    2022-01-14 12:00:51 INFO: Running Get-GivenName function
    2022-01-14 12:00:56 INFO: Given name retrieved from Active Directory: Oleksandr
    2022-01-14 12:00:56 INFO: Creating the xml for no action button
    2022-01-14 12:00:56 INFO: Creating the xml for displaying the second action button: actionbutton2
    2022-01-14 12:00:56 WARNING: This will always enable both action buttons and the dismiss button
    2022-01-14 12:00:56 WARNING: Replacing any previous formatting of the toast xml
    2022-01-14 12:00:56 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    2022-01-14 12:00:56 INFO: Toast notification is used in regards to pending reboot. Uptime count is greater than -6
    2022-01-14 12:00:56 INFO: Confirmed USER context before displaying toast
    2022-01-14 12:00:58 INFO: All good. Toast notification was displayed

    Config File @config-toast.xml@




































    Your computer is required to restart due to having exceeded the maximum allowed uptime.
    Reason: Pending reboots was found in registry or WMI.
    Your password will expire on:
    Hey you – wake up. Your computer needs to restart. Do it now.
    Restart now
    Learn More
    Dismiss
    Snooze
    https://www.imab.dk
    Helpdesk kindly reminds you…
    Your computer needs to restart!
    For security and stability reasons, we kindly ask you to restart your computer as soon as possible.
    Restarting your computer on a regular basis ensures a secure and stable Windows. Thank you in advance.
    Click snooze to be reminded again in:
    Your deadline is:
    Good morning
    Good afternoon
    Good evening
    Minutes
    Hour
    Hours
    Computer uptime:
    days

    Reply
    • config-toast.xml




































      Your computer is required to restart due to having exceeded the maximum allowed uptime.
      Reason: Pending reboots was found in registry or WMI.
      Your password will expire on:
      Hey you – wake up. Your computer needs to restart. Do it now.
      Restart now
      Learn More
      Dismiss
      Snooze
      https://www.imab.dk
      Helpdesk kindly reminds you…
      Your computer needs to restart!
      For security and stability reasons, we kindly ask you to restart your computer as soon as possible.
      Restarting your computer on a regular basis ensures a secure and stable Windows. Thank you in advance.
      Click snooze to be reminded again in:
      Your deadline is:
      Good morning
      Good afternoon
      Good evening
      Minutes
      Hour
      Hours
      Computer uptime:
      days

      Reply
    • You haven’t changed the MaxUptimeDays value. It’s still configured to -6. How many days do you allow your devices to run, before you want to nag them about rebooting? If 3 days, configure the config.xml accordingly to 3 and not -6 🙂

      Reply
      • Do I need to specify the maximum number of days without a reboot without the “-” symbol?

        Is that the whole problem?!

        Since the conditions are no more than 6 days, it suits me

        Reply
          • So I incorrectly translated the text from English into my native language.

            Thank you very much for your help))

  252. Hi!
    This is my config-toast.xml
    ______________________________________________________




































    Your computer is required to restart due to having exceeded the maximum allowed uptime.
    Reason: Pending reboots was found in registry or WMI.
    Your password will expire on:
    Hey you – wake up. Your computer needs to restart. Do it now.
    Restart now
    Learn More
    Dismiss
    Snooze
    https://www.imab.dk
    Helpdesk kindly reminds you…
    Your computer needs to restart!
    For security and stability reasons, we kindly ask you to restart your computer as soon as possible.
    Restarting your computer on a regular basis ensures a secure and stable Windows. Thank you in advance.
    Click snooze to be reminded again in:
    Your deadline is:
    Good morning
    Good afternoon
    Good evening
    Minutes
    Hour
    Hours
    Computer uptime:
    days

    Din computer er påkrævet at genstarte, da den har overskredet den maksimale oppetid.
    Årsag: Udestående genstart fundet i registry eller WMI.
    Dit password vil udløbe:
    Hej dig – vågn op. Din computer skal genstarte. Gør det nu.
    Genstart nu
    Mere Info
    Afvis
    Udskyd
    https://www.imab.dk
    En venlig påmindelse fra Helpdesk
    Din computer skal genstarte!
    Af hensyn til din computers sikkerhed og stabilitet, beder vi dig genstarte din computer snarest muligt.
    At genstarte sin computer regelmæssigt, er med til at sikre et sikkert og stabilt Windows. På forhånd tak.
    Klik udskyd for at blive påmindet igen om:
    Din tidsfrist er:
    Godmorgen
    God eftermiddag
    Godaften
    Minutter
    Time
    Timer
    Computer oppetid:
    dage

    Din dator behöver startas om då den överskridit den maximala tillåtna upptiden.
    Orsak: Väntande omstart hittades i registret eller WMI.
    Ditt lösenord går ut:
    Hej du – vakna upp. Datorn måste starta om. Gör det nu.
    Starta Om
    Starta Om
    Stäng
    Påminn
    https://www.imab.dk
    En vänlig påminnelse från IT…
    Din dator behövs starta om
    För att kunna garantera datorns säkerhet och stabilitet ber vi dig att starta om datorn så snart som möjligt.
    Att starta om sin dator regelbundet bidrar till en stabilare och säkrare It-miljö. Tack på förhand!
    Klicka på Påminn för att bli påmind igen:
    Slutdatum är:
    God morgon
    God eftermiddag
    God kväll
    Minuter
    Timma
    Timmar
    Datorns upptid:
    dagar

    _______________________________________________

    Log file:

    2022-01-15 21:10:26 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-01-15 21:10:26 INFO: Script is initially running in USER context
    2022-01-15 21:10:26 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2022-01-15 21:10:26 INFO: Successfully loaded \\sccm\source\RebootNotification\config-toast.xml
    2022-01-15 21:10:26 INFO: Loading xml content from \\sccm\source\RebootNotification\config-toast.xml into variables
    2022-01-15 21:10:26 INFO: Successfully loaded xml content from \\sccm\source\RebootNotification\config-toast.xml
    2022-01-15 21:10:26 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2022-01-15 21:10:26 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2022-01-15 21:10:26 INFO: Running Get-DeviceUptime function
    2022-01-15 21:10:27 INFO: PendingRebootUptime set to True. Checking for device uptime. Current uptime is: 1 days
    2022-01-15 21:10:27 INFO: Greeting with given name selected. Replacing HeaderText
    2022-01-15 21:10:27 INFO: Greeting with personal greeting: Good evening
    2022-01-15 21:10:27 INFO: Running Get-GivenName function
    2022-01-15 21:10:27 INFO: Given name not found in AD or no local AD is available. Continuing looking for given name elsewhere
    2022-01-15 21:10:27 INFO: Given name not found in registry. Using nothing as placeholder
    2022-01-15 21:10:27 INFO: Creating the xml for no action button
    2022-01-15 21:10:27 INFO: Creating the xml for displaying the second action button: actionbutton2
    2022-01-15 21:10:27 WARNING: This will always enable both action buttons and the dismiss button
    2022-01-15 21:10:27 WARNING: Replacing any previous formatting of the toast xml
    2022-01-15 21:10:27 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    2022-01-15 21:10:27 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    2022-01-15 21:10:27 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    2022-01-15 21:10:27 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    2022-01-15 21:10:27 WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    2022-01-15 21:10:27 WARNING: Conditions for displaying default toast notification are not fulfilled

    Running through CB SCCM, as a package under user rights

    The xml file is on a share the user can read. Running Win 11.

    where is the “local” file supposed to be? any ideas on the warnings? thanks

    Reply
    • What kind of toast are you expecting to see? Not of the conditions to display any of the toasts are fulfilled, therefore you don’t see any. 🙂

      Reply
      • Ok, so how do i enable any of these conditions?
        Conditions for displaying toast notifications for pending reboot uptime are not fulfilled (where are these conditions? in the config-=toast.xml?

        where in the registry is this? what key or value is queried?
        Conditions for displaying toast notifications for pending reboot registry are not fulfilled

        thanks

        Reply
        • The script does not query the registry in this case. Have a look at the Get-DeviceUptime function. It queries WMI. 🙂

          Reply
      • it says: WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
        I have it set to toast notify if its more than 4 days, thus, if i read this correct, since the machine has been up only 2 days no notification will appear, but after 4 days, then i should get a notification screen.
        Correct?

        Reply
        • If you configure MaxUptimeDays in the config.xml file to 4, your computers needs to have an uptime more than 4 days in order to see the toast notification, that’s correct 🙂

          Reply
  253. Hey Martin,
    Love this, but running into a weird scenario. I’m testing this a MECM package, running it with user rights as instructed. Here is the command I am running: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config config-toast.xml

    However, when I test on my machine and a few coworkers, it runs fine as expected. Folders/log file gets created in Appdata and the toast displays. When I test on a few people outside of my team, it doesn’t create anything so I can’t look at any log files to troubleshoot. I just get this in the execmgr.log file: Script for Package:XXXXXXXX, Program: Run Toast Notification failed with exit code 1

    The only difference between us and them are local admin rights. Any ideas why this would affect it?

    Reply
    • Hey Todd, exit code 1 represent some sort of error in the execution of my script. If anything goes unexpected, I exit with 1. This seem to happen even before the log file is created.

      On those devices where this fails, are you able to run the script manually outside of ConfigMgr with the same cmdline from within PowerShell?

      Reply
  254. Hi Martin,
    Yes I am able to. I just tested it with my test account that has no admin rights. I had to set the execution policy to bypass first, but that’s expected. Here is the output from the PowerShell window…

    PS C:\windows\ccmcache\q> .\New-ToastNotification.ps1 -config .\config-toast.xml
    VERBOSE: Creating C:\Users\tchristensen-test\AppData\Roaming\ToastNotificationScript\New-ToastNotification.log.
    VERBOSE: ToastNotificationScript registry path not found. Creating it: HKCU:\SOFTWARE\ToastNotificationScript
    VERBOSE: CustomScriptPath not found. Creating it:
    C:\Users\tchristensen-test\AppData\Roaming\ToastNotificationScript\Scripts
    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Script is initially running in USER context
    VERBOSE: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    VERBOSE: Successfully loaded .\config-toast.xml
    VERBOSE: Loading xml content from .\config-toast.xml into variables
    VERBOSE: Successfully loaded xml content from .\config-toast.xml
    VERBOSE: Running Register-NotificationApp function
    VERBOSE: Created registry entries for custom notification app: LTCG NOTIFICATIONS!
    VERBOSE: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    VERBOSE: Registry value of ScriptsAndProtocolsVersion does not match Script version: 2.3.0
    VERBOSE: Creating scripts and protocols for the logged on user
    VERBOSE: Running Write-CustomActionRegistry function: ToastReboot
    VERBOSE: Running Write-CustomActionRegistry function: ToastRunApplicationID
    VERBOSE: Running Write-CustomActionRegistry function: ToastRunPackageID
    VERBOSE: Running Write-CustomActionRegistry function: ToastRunUpdateID
    VERBOSE: Running Write-CustomActionScript function: ToastReboot
    VERBOSE: Running Write-CustomActionScript function: ToastRunApplicationID
    VERBOSE: Running Write-CustomActionScript function: ToastRunPackageID
    VERBOSE: Running Write-CustomActionScript function: ToastRunUpdateID
    VERBOSE: Running Write-CustomActionScript function: InvokePSScriptAsUser

    Hive: HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings

    Name Property
    —- ——–
    Toast.Custom.App

    ShowInActionCenter : 0
    PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\No
    tifications\Settings\Toast.Custom.App
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\No
    tifications\Settings
    PSChildName : Toast.Custom.App
    PSDrive : HKCU
    PSProvider : Microsoft.PowerShell.Core\Registry

    Enabled : 1
    PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifica
    tions\Settings\Toast.Custom.App
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifica
    tions\Settings
    PSChildName : Toast.Custom.App
    PSDrive : HKCU
    PSProvider : Microsoft.PowerShell.Core\Registry

    SoundFile :
    PSPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifica
    tions\Settings\Toast.Custom.App
    PSParentPath : Microsoft.PowerShell.Core\Registry::HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifica
    tions\Settings
    PSChildName : Toast.Custom.App
    PSDrive : HKCU
    PSProvider : Microsoft.PowerShell.Core\Registry

    VERBOSE: Greeting with given name selected. Replacing HeaderText
    VERBOSE: Greeting with Good morning
    VERBOSE: Running Get-GivenName function
    VERBOSE: Given name retrieved from Active Directory: Todd
    VERBOSE: Creating the xml for no action button
    WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    WARNING: Conditions for displaying toast notification for ADPasswordExpiration are not fulfilled
    VERBOSE: Toast notification is not used in regards to OS upgrade OR Pending Reboots OR ADPasswordExpiration. Displaying
    default toast
    VERBOSE: Confirmed USER context before displaying toast
    VERBOSE: All good. Toast notification was displayed
    All good. Toast notification was displayed

    Tried again on the same system via MECM, and still get the same error code 1.

    Reply
    • Can I get you to try without specifying the -config parameter? I’m assuming you are leaving the config-toast.xml within the same package with the default name, right? Try to run it via memcm without the -config parameter.

      Reply
      • Hi Martin,
        I removed the -config parameter like you asked. Running it manually works, but I still get the exit code 1 from MECM. Below is the output from the execmgr.log file for running it…

        Executing program as a script execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Found executable file Powershell.exe with complete path C:\WINDOWS\System32\WindowsPowerShell\v1.0\Powershell.exe execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Successfully prepared command line “C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe” -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Command line = “C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe” -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1, Working Directory = C:\WINDOWS\ccmcache\q\ execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Running “C:\WINDOWS\System32\WindowsPowerShell\v1.0\powershell.exe” -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 with 32bitLauncher execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Created Process for the passed command line execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Raising event:
        [SMS_CodePage(437), SMS_LocaleID(1033)]
        instance of SoftDistProgramStartedEvent
        {
        AdvertisementId = “P0020607”;
        ClientID = “GUID:3CB295E0-B1F9-4AAD-AE52-2AC44AB16386”;
        CommandLine = “\”C:\\WINDOWS\\System32\\WindowsPowerShell\\v1.0\\powershell.exe\” -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\\New-ToastNotification.ps1″;
        DateTime = “20220119172118.060000+000”;
        MachineName = “HPV_TLC3”;
        PackageName = “P0000466”;
        ProcessID = 3844;
        ProgramName = “Run Toast Notification”;
        SiteCode = “P00”;
        ThreadID = 3172;
        UserContext = “CORP\\tchristensen-test”;
        WorkingDirectory = “C:\\WINDOWS\\ccmcache\\q\\”;
        };
        execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Raised Program Started Event for Ad:P0020607, Package:P0000466, Program: Run Toast Notification execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Raising client SDK event for class CCM_Program, instance CCM_Program.PackageID=”P0000466″,ProgramID=”Run Toast Notification”, actionType 1l, value NULL, user NULL, session 4294967295l, level 0l, verbosity 30l execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Raising client SDK event for class CCM_Program, instance CCM_Program.PackageID=”P0000466″,ProgramID=”Run Toast Notification”, actionType 1l, value , user NULL, session 4294967295l, level 0l, verbosity 30l execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        EvaluateRequestForExecution – Updated current running request execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        MTC task with id {E512787C-ACB8-4135-957D-3514CBD407BF}, changed state from 4 to 5 execmgr 1/19/2022 11:21:18 AM 3172 (0x0C64)
        Program exit code 1 execmgr 1/19/2022 11:21:18 AM 1712 (0x06B0)

        Reply
        • Tough one without the script’s own log file. Hmm. Do you have anything configured, that could prevent this from running? You mentioned it worked on some of your devices, but not the one outside of your team. Is it intentional that you don’t configure -ExecutionPolicy Bypass? Does other PowerShell scripts run fine on all devices as well?

          Reply
  255. Hi,

    Toast notification for informing user and allow to snooze for some time before runinng complicated task sequence. Any ideas how to ….?

    Reply
    • The toast notification itself can’t do anything automatically for you, but you can have the action button to launch a task sequence and you can allow to snooze the toast notification as well, you just can’t have the toast notification automatically do something for you. The user has to click the buttons.

      Reply
  256. I keep getting this error, running script under user rights as a package via sccm CB against Windows 11 machine. Intermittent. Sometimes it works fine, others…
    ________________________________________

    VERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Script is initially running in USER context
    VERBOSE: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    Write-Log : No config file found on the specified location [locally or fileshare]
    At C:\WINDOWS\ccmcache\k\New-ToastNotification.ps1:1623 char:9
    + Write-Log -Level Error -Message “No config file found on the …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    [process exited with code 1]

    Where should this script be copied “locally”? the fileshare has everyone has read & execute rights.

    thanks

    Reply
    • Looks like there’s intermittent issues with access to the config file? No other way to explain it I guess. Have you considered keeping the config.xml in the package with the New-ToastNotification.ps1 file instead, to remove the dependency of accessing the file share? 🙂

      Reply
  257. the PS1 and the XML are both in the CCMCACHE directory which is mentioned in your log file (C:\WINDOWS\ccmcache\k) and in the source folder where the script and xml file was originally placed.
    Where should the local copy of the xml files be housed? C:\Users\\AppData\Roaming\ToastNotificationScript is the folder i am guessing and the PS1 and xml file are there already.

    Reply
  258. Why do I I keep getting this error? I don’t see any documentation on how to set custom app to false.

    ERBOSE: Running supported version of Windows. Windows 10 and workstation OS detected
    VERBOSE: Script is initially running in USER context
    VERBOSE: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    VERBOSE: Successfully loaded .\config-toast-rebootpending.xml
    VERBOSE: Loading xml content from .\config-toast-rebootpending.xml into variables
    VERBOSE: Successfully loaded xml content from .\config-toast-rebootpending.xml
    Write-Log : Error. Conflicting selection in the .\config-toast-rebootpending.xml file
    At C:\temp\Toast_notification\New-ToastNotification.ps1:1805 char:5
    + Write-Log -Level Error -Message “Error. Conflicting selection in …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Write-Log : Error. You can’t have both SoftwareCenter app set to True AND CustomNotificationApp set to True at the
    same time. Check your config
    At C:\temp\Toast_notification\New-ToastNotification.ps1:1806 char:5
    + Write-Log -Level Error -Message “Error. You can’t have both Softw …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : NotSpecified: (:) [Write-Error], WriteErrorException
    + FullyQualifiedErrorId : Microsoft.PowerShell.Commands.WriteErrorException,Write-Log

    Reply
    • You have 3 options in regards to what app is doing the notification. Only one can be used. So if you want software center to be the notifying app, you disable powershell and the custom app. (only one can be set to true)

      Reply
  259. I saw your response in another post that said we can not run a script from inside the new-toastnotification.ps1 file.

    would this work?
    I would like to call your script, new-toast notification from inside another script that when a specific button is pressed, it will complete an action.

    Can the buttons be configured to return a specific exit code that can then be used inside the wrapper script to execute a command?

    Reply
  260. Some feedback for you.

    It would make more sense to have a single XML file, and allow multiple options to all be checked and trigger various (possibly multiple toasts) without the need to deploy multiple versions of the script/xml to endpoints. It would be really nice to have an all in one configuration to check account password, pending reboot, and uptime all in one go, and display the appropriate notifications without needing 3 separate XML files & deployments to do so.

    Another improvement would be to only use the True/False on enabling the notifications themselves, not the texts to be displayed. For example, if I’ve selected True for PendingRebootUptime, it should just assume PendingRebootUptimeText is true & should have something in it (along with all the other associated options as well). The only thing I can see having additional True/False on would be turning buttons like Snooze on and off.

    Lastly if a text such as Text Name=”AttributionText” has been left blank, it should not throw an error. Instead script should assume to just leave that out of the notification.

    Looking forward to the next release, hopefully with some of these quality of life improvements.

    Reply
    • Oh another I thought of at the last minute. How is a standard user to check the pending reboot registry keys? They do not have access to those keys without elevated / admin permissions on the workstation. So these notifications never display when the script is run in the context of the user.

      Reply
      • The Test-PendingRebootRegistry function does not require admin privileges to simply query the registry values. Nothing in the script does that. 🙂

        Reply
  261. Hi,

    We love to work with the toast it is really great.

    We face off an issue to run application (User-Available) with the toast.

    It works great with the AppID (Scope_xxxxxxxx) when application is device targeted or user when is required. But when application is user available, we see it in the Software Center but not in WMI (CCM_Application class).

    Already read a lot of post on the web but nobody has an answer about this topic.

    Did you have an idea to perform installation of an application (User-Available) with the toast ?

    Thanks in advance for your help.

    Kind regards.

    Arthur Dalpiaz from D’Ieteren in Belgium.

    Reply
  262. Hi Martin

    Just saying what everybody already said: I love this!
    I’ve implemented the reboot and windows upgrade function of your script without much hassle and so far, everything works as expected 🙂

    Not sure if this is the right location to ask, but can your script be adjusted to trigger a toast on a certain event? (eg. applocker?)
    For the moment I’m using burnttoast for this, but it would be convenient by using yours 😉

    Keep up the good work and I’m looking forward for newer releases.

    Reply
  263. where do i get the “Windows 10 Toast Notification Script Reboot Protocol.msi” file from. It’s no longer in the 2.3 folder, but used to be in the 2.1. Without it, the script doesn’t reboot when user hits reboot. thanks

    Reply
    • Those custom scripts is created by the New-ToastBotificationScript.ps1 itself via the CustomScriptsandProtocol option in the config.xml 🙂

      Reply
  264. I am actually greatly enjoying using this script for all sorts of things, particularly user initiated software deployments, but most of all I am enjoying using it to both harass and humor users with the audio function. This is particularly useful in a high density laptop, remote work environment. Kicking these off at 6:30 PM with a “While you’re enjoying dinner, I still haven’t been rebooted in a week” has hilarious results. And guess what, the user hits reboot rather than dismiss.

    The only two things I’d like to know, and or wish to be implemented:

    1) Would there be a way to use the user’s name, or the uptime, or any other variable a part of the audio function? That would be next level.

    2) Anybody figure out a way to call a Company Portal app directly via a protocol handler. I figured out the one that can get the toast to open company portal *to* the app page, but the user still has to click the install button.. I can’t figure out what the button url/handler is.

    Reply
    • That’s some great suggestions. Regarding question 2, I’m haven’t been able to find any information on how to do this I’m afraid.

      Reply
  265. Hello,
    Any idea why this happen?
    I use the precache and precache-install TS to upgrade from 1909 to 21H2.

    I still run after so many errors.

    Start executing an instruction. Instruction name: ‘Test Readiness Failure’. Pointer: 15. Type: ‘SMS_TaskSequence_PrestartCheckAction’. Disabled: 0
    Set a global environment variable _SMSTSCurrentActionName=Test Readiness Failure
    The action (Test Readiness Failure) has been skipped because the condition is evaluated to be false
    Execution of the instruction (Test Readiness Failure) has been skipped

    Start executing an instruction. Instruction name: ‘Readiness Failed’. Pointer: 21. Type: ”. Disabled: 0
    Set a global environment variable _SMSTSCurrentActionName=Readiness Failed
    The group (Readiness Failed) has been skipped because the condition is evaluated to be false
    Execution of the instruction (Readiness Failed) has been skipped

    Start executing an instruction. Instruction name: ‘Test PreCache Failure’. Pointer: 35. Type: ‘SMS_TaskSequence_RunCommandLineAction’. Disabled: 0
    Set a global environment variable _SMSTSCurrentActionName=Test PreCache Failure
    The action (Test PreCache Failure) has been skipped because the condition is evaluated to be false
    Execution of the instruction (Test PreCache Failure) has been skipped

    Start executing an instruction. Instruction name: ‘PreCache Failed’. Pointer: 51. Type: ”. Disabled: 0
    Set a global environment variable _SMSTSCurrentActionName=PreCache Failed
    The group (PreCache Failed) has been skipped because the condition is evaluated to be false
    Execution of the instruction (PreCache Failed) has been skipped

    Thank you so much

    Elshaday

    Reply
  266. Hi Martin,

    Any idea for this please?

    Failed to open to WMI namespace ‘\\.\ROOT\CIMV2’ (80040154)
    Failed to connect to WMI namespace \\.\ROOT\CIMV2 (Code 0x80040154)
    Failed to find property ‘AutoApplyDeployment’ in ‘CCM_ApplicationManagementClientConfig’ class definition. Error 0x80041002. Default value will be used for this property
    Parsing step node: Test Readiness Failure
    Parsing group node: Readiness Failed
    Parsing step node: Set ReadinessStatus Failed
    Operand Path=z:\%computername%\ReadinessFailed
    Parsing step node: Readiness Failed
    Parsing step node: Test PreCache Failure
    Parsing group node: PreCache Failed
    Parsing step node: Set PreCacheStatus Failed
    Operand Path=z:\%computername%\PreCacheFailed
    Parsing step node: PreCache Failed
    Parsing step node: Set CompatScanStatus Failed
    Parsing group node: OS Compat Scan Failed
    Parsing step node: Set OS CompatScanStatus Failed
    Operand Path=z:\%computername%\CompatScanFailed
    Parsing step node: CompatScan Failed
    Failed to create an instance of COM progress UI object. Error code 0x8000401a

    Thanks

    Daniel

    Reply
  267. Love this script. I am trying to utilize it to prompt my users to take a survey. The issue I am having is that I dont want to open the site in the default browser as the website is not supported in IE. Most machines do not yet have edge installed and are instead installed with Chrome.

    Is there anyway that I can set an action to specifically open Chrome? Or possibly run a .bat from an action?

    Any input is greatly appreciated, Thank you.

    Reply
  268. can someone help me how to configure a toast notification with 2 buttons
    1. with costume action (script that ill provide)
    2. snooze button (i decide how many are allowed)

    Reply
    • Hello, I’m afraid not. There’s no way to customize the fonts. This is entirely handled by the OS itself and the theme you use in Windows (if any).

      Reply
  269. Hey!
    Very nice script!

    I got a problem with the Scenario.
    Using Version 2.3.0

    When its set to reminder and no enabled buttons at all its displayed for 15 seconds. Then it just vanishes from the notification center. When buttons are present its not vanishing and you have to actively press something. (Thats basically what i would want from “reminder”)

    When its set to “short”, “long” or “alert”, its vanishing after 15 sec (on all 3) regardless if there are any buttons enabled or not. It’s just gone. I would have expected the same behavior like “reminder”, the only difference being displayed for a shorter time AND still being visible in the notification center.

    Is this only happening for me?

    Reply
  270. Can I open a different browser than default or Edge with the action buttons?

    What about running a .bat file?

    I really just want to be able to open chrome specifically.

    Reply
    • I actually don’t know. This is not directly related to the script. The script is based on a framework, which is able to launch protocol based actions, like https://yadayada. The OS then knows, that this protocol is associated with your default browser. The OS is then opening your default browser, not the script.

      Reply
    • Running a .bat file is possible. That’s what I do for all of the custom actions, like rebooting the device or launching a task sequence in the Software Center.

      Reply
  271. Using toast to upgrade to 21H2 (19044).

    However the “” is not working, and users are still seeing Toast notification after successful upgrade.

    to mitigate, I have added excluded 19044 collection from the toast notification, but there is latency. Would be better if the option in the XML was working as intended.

    Thoughts?

    Reply
    • Have you tested that specifically and correctly? if I run the toast with the UprgadeOS option enabled and the TargetOS is configured properly, the toast is not shown if the OS the script is running on, is matching that configured in the TargetOS option.

      Reply
  272. Good day sir,

    love your work. One question. I am building a toast notification to let people know their drivers are outdated and allow them to install with a click of a button. Now I would love to build a counter for the dismiss button. If they dismiss like five times, the drivers would install. Is there any way to add logic to the dismiss button? Maybe like a short powershell script…or add increments of +1 to a registry key value etc..Thank you!

    Reply
  273. This script has been amazing! I’m running into an issue today though with the RunApplicationID.
    I can see in the log file that the script sees it. The toast will launch but when you press the Upgrade Now button, I get a pop up box with Windows wanting to know how to open the file.

    Any thoughts?

    Reply
    • Hm, sounds like the custom protocol somehow has been deleted?

      Doe you have any entries here?: Computer\HKEY_CURRENT_USER\Software\Classes\ToastRunApplicationID\shell\open\command

      And does the entry point to the script in appdata\toastnotificationscript\Scripts?

      Reply
  274. Hi there, I am trying to run the toast script but either running from a network share or local it errors out with Cannot convert value “system Object[]” to type “system.Xml.XmlDocument” error “An error occurred when parsing Entity Name . Line 49, position 136.” same when I run form a network share or just the .\New-ToastNotification.ps1.. Any idea what can bet= the cause of this?, I have fully deleted it off a couple of times and redone new and still the same :(. Hope you can advise 🙂 Thanks Robert

    Reply
  275. Love the script. Running the powershell command manually works as expected. When I deploy via SCCM it just shows a condensed message that says powershell and doesn’t show the actual full message, it doesn’t contain any details, just says powershell.exe notification. Below are the logs but they say successful. Any help appreciated.

    2022-04-26 13:20:07 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-04-26 13:20:07 INFO: Script is initially running in USER context
    2022-04-26 13:20:07 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2022-04-26 13:20:07 INFO: Successfully loaded \\fullnetworklocation\config-toast-adpwexpiration.xml
    2022-04-26 13:20:07 INFO: Loading xml content from \\fullNetworklocation\config-toast-adpwexpiration.xml into variables
    2022-04-26 13:20:09 INFO: Successfully loaded xml content from \\fullNetworklocation\config-toast-adpwexpiration.xml
    2022-04-26 13:20:09 INFO: Toast notification was previously displayed 22 minutes ago
    2022-04-26 13:20:09 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2022-04-26 13:20:09 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2022-04-26 13:20:09 INFO: ADPasswordExpiration set to True. Checking for expiring AD password
    2022-04-26 13:20:09 INFO: Running Get-ADPasswordExpiration function
    2022-04-26 13:20:09 INFO: Looking up SamAccountName and DomainName in local Active Directory
    2022-04-26 13:20:10 INFO: SamAccountName found: test and DomainName found: xxxxx.net. Continuing looking for AD password expiration date
    2022-04-26 13:20:10 INFO: Password expiration date found. Password is expiring on 06/24/2022 13:28:30. Calculating time to expiration
    2022-04-26 13:20:10 INFO: Password is expiring within the set period. Returning True
    2022-04-26 13:20:10 INFO: ADPasswordExpirationDays is set to: 90
    2022-04-26 13:20:10 INFO: Greeting with given name selected. Replacing HeaderText
    2022-04-26 13:20:10 INFO: Greeting with Good afternoon
    2022-04-26 13:20:10 INFO: Running Get-GivenName function
    2022-04-26 13:20:10 INFO: Given name retrieved from Active Directory: Test
    2022-04-26 13:20:11 INFO: Creating the xml for no action button
    2022-04-26 13:20:11 WARNING: Conditions for displaying toast notifications for UpgradeOS are not fulfilled
    2022-04-26 13:20:11 WARNING: Conditions for displaying toast notifications for pending reboot uptime are not fulfilled
    2022-04-26 13:20:11 WARNING: Conditions for displaying toast notifications for pending reboot registry are not fulfilled
    2022-04-26 13:20:11 WARNING: Conditions for displaying toast notifications for pending reboot WMI are not fulfilled
    2022-04-26 13:20:11 INFO: Toast notification is used in regards to ADPasswordExpiration. ADPasswordExpirationResult returned True
    2022-04-26 13:20:11 INFO: Confirmed USER context before displaying toast
    2022-04-26 13:20:11 INFO: All good. Toast notification was displayed

    Reply
    • Hm, are you running the new-toastnotification.ps1 from a network share? You are welcome to take this offline with me on mab@imab.dk and include some screenshots of your config in configmgr as well as the output when running it from configmgr. Thank you.

      Reply
  276. Hello Together,

    is it possible to kill a process (running exe) with an Action Option? Just to click Action Button 1 and this kills the exe? Maybe with a Powershell command? If yes, how can it be done?

    Best regards,
    Alex

    Reply
  277. Hello Martin,

    I’ve configured the config-toast-osupgrade.xml and ran the New-ToastNotification.ps1 -Config .\config-toast-osupgrade.xml.
    Didn’t receive any errors in the log, only two warnings. The problem is that the toast doesn’t pop up.
    Here is the log. I don’t know what else to check or modify.

    2022-05-05 17:36:46 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-05-05 17:36:46 INFO: Script is initially running in USER context
    2022-05-05 17:36:46 INFO: Toast notifications for the logged on user are enabled in Windows
    2022-05-05 17:36:46 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2022-05-05 17:36:46 INFO: Successfully loaded .\config-toast-osupgrade.xml
    2022-05-05 17:36:46 INFO: Loading xml content from .\config-toast-osupgrade.xml into variables
    2022-05-05 17:36:49 INFO: Successfully loaded xml content from .\config-toast-osupgrade.xml
    2022-05-05 17:36:49 INFO: Toast notification was previously displayed 15 minutes ago
    2022-05-05 17:36:49 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2022-05-05 17:36:49 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2022-05-05 17:36:49 INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    2022-05-05 17:36:49 INFO: Running Write-PackageIDRegistry function
    2022-05-05 17:36:49 INFO: PackageID: PRI0028A was found in WMI as deployed to the client
    2022-05-05 17:36:49 INFO: Writing the PackageID to registry
    2022-05-05 17:36:49 INFO: DynDeadlineEnabled set to True. Overriding deadline details using date and time from WMI
    2022-05-05 17:36:49 INFO: Running Get-DynamicDeadline function. Trying to get deadline details from WMI and ConfigMgr
    2022-05-05 17:36:49 INFO: RunPackageIDEnabled is True. Trying to get deadline information based on package id
    2022-05-05 17:36:49 INFO: PackageID retrieved. PackageID is: PRI0028A. Now getting deadline date and time
    2022-05-05 17:36:49 INFO: Deadline date and time successfully retrieved from WMI. Deadline is: 05/11/2022 11:00:00
    2022-05-05 17:36:49 INFO: Greeting with given name selected. Replacing HeaderText
    2022-05-05 17:36:49 INFO: Greeting with personal greeting: Good evening
    2022-05-05 17:36:49 INFO: Running Get-GivenName function
    2022-05-05 17:36:49 INFO: Given name retrieved from Active Directory: Krasimir
    2022-05-05 17:36:49 INFO: Creating the xml for action button and dismiss button
    2022-05-05 17:36:49 INFO: Creating the xml for displaying the second action button: actionbutton2
    2022-05-05 17:36:49 WARNING: This will always enable both action buttons and the dismiss button
    2022-05-05 17:36:49 WARNING: Replacing any previous formatting of the toast xml
    2022-05-05 17:36:49 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2022-05-05 17:36:49 INFO: Confirmed USER context before displaying toast
    2022-05-05 17:36:49 INFO: All good. Toast notification was displayed

    Best regards and thanks in advance.
    Krasimir

    Reply
    • Hello,

      Just found that “focus assist” was enabled.
      Had to turn it off and the toast popped up.

      BR
      Krasimir

      Reply
  278. Just started working with your script and it looks great, I’ve got a working version of the uptime exceeds x days and pending restart working. Trying to get the OS upgrade portion to work, it is doing the toast notification but when clicking the ‘Install’ button a command window flashes for a moment and then nothing else happens. Here is what I’m seeing in the log –
    2022-05-13 10:40:26 INFO: Script Started
    2022-05-13 10:40:26 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-05-13 10:40:26 INFO: Script is initially running in USER context
    2022-05-13 10:40:26 INFO: Toast notifications for the logged on user are enabled in Windows
    2022-05-13 10:40:26 INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    2022-05-13 10:40:26 INFO: Successfully loaded C:\Program Files (x86)\xxx\UserToastNotifications\config-toast-uptime.xml
    2022-05-13 10:40:26 INFO: Loading xml content from C:\Program Files (x86)\xxx\UserToastNotifications\config-toast-uptime.xml into variables
    2022-05-13 10:40:27 INFO: Successfully loaded xml content from C:\Program Files (x86)\xxx\UserToastNotifications\config-toast-uptime.xml
    2022-05-13 10:40:27 INFO: Toast notification was previously displayed 4 minutes ago
    2022-05-13 10:40:27 INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    2022-05-13 10:40:27 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols
    2022-05-13 10:40:27 INFO: RunUpdateID set to True. Will allow execution of Software UpdateID (KB-article number) directly from the toast action button
    2022-05-13 10:40:27 INFO: Running Write-UpdateIDRegistry function
    2022-05-13 10:40:27 INFO: Running Get-CMUpdate function
    2022-05-13 10:40:27 INFO: Found update that matches UpdateID: 5003791 and name: Feature Update to Windows 10 Version 21H2 x64-based systems 2021-11 via Enablement Package
    2022-05-13 10:40:27 INFO: Get-CMDUpdate was successfully run and UpdateID was retrieved
    2022-05-13 10:40:27 INFO: Writing the UpdateID to registry
    2022-05-13 10:40:27 INFO: Greeting with given name selected. Replacing HeaderText
    2022-05-13 10:40:27 INFO: Greeting with Good morning
    2022-05-13 10:40:27 INFO: Running Get-GivenName function
    2022-05-13 10:40:27 INFO: Given name retrieved from Active Directory: xxx
    2022-05-13 10:40:27 INFO: Creating the xml for action button and dismiss button
    2022-05-13 10:40:27 INFO: Creating the xml for displaying the second action button: actionbutton2
    2022-05-13 10:40:27 WARNING: This will always enable both action buttons and the dismiss button
    2022-05-13 10:40:27 WARNING: Replacing any previous formatting of the toast xml
    2022-05-13 10:40:27 INFO: Toast notification is used in regards to OS upgrade. Taking running OS build into account
    2022-05-13 10:40:27 INFO: Confirmed USER context before displaying toast
    2022-05-13 10:40:27 INFO: All good. Toast notification was displayed

    I’m specifying the KB in the following spot –

    Based on the logs it appears to be checking SCCM policy on the endpoint, finding the KB and the name of the KB but just not starting the install process. Thoughts on what to look at next?

    Thanks!

    Reply
  279. Hello, just downloaded the latest version from GitHub and change the “UseSoftwareCenterApp” to false as I’m getting a ” Cannot find any service with service name ‘ccmexec’.” error. The notification works fine but when I click Restart Now button, nothing happens. I don’t have any SCCM but I have an MDM so I was thinking to deploy it via script.

    Reply
  280. Hey there!

    I dig this script, and I’ve been trying to modify it to just pop up a toast to notify our users that there will be automatic updates in the evening. I simply want it to say “Hi, your computer will update tonight, please leave your computer powered on and connected to the internet”. I built a new.xml file (called UpdateTonight) and I think I have all of the variables set up right. I also modified the RunToastHidden.cmd file to reflect the different filename, and I went through the New-ToastNotification.ps1 file to get it to see the new .xml file. I continually get the toast for Computer Uptime though, so there is something not right…

    As I was going through the .ps1 another time, it looks like I need to create a new function for the .xml file I created, but since I am just starting out with learning PowerShell (I rely on masters on the internet) I don’t know how do do that.. I would try to modify another of the functions and files to do what I need, but they all grab info from other sources and I don’t want to mess anything up that needs to function.

    Has any work been done on simple notifications to the user? I don’t need action or delay buttons, and I don’t need it to reference any other applications. I just want it to pop up a notification on Thursday afternoons that there will be an update that evening.

    Thanks in advance!!

    Reply
  281. When a TOAST is presented for a user they have the opportunity to disable notifications from Software Center by clicking on the three dots left to the X “exit button” and choose to disable notifications from Software Center
    That sets:
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts /v Enabled to 0
    IF I change that to 1 and run it in as current logged on user (same as the one that disabled it) it changes :
    HKEY_CURRENT_USER\SOFTWARE\Microsoft\Windows\CurrentVersion\Notifications\Settings\Microsoft.SoftwareCenter.DesktopToasts /v Enabled to 1
    and I can see that the button is enabled again to show notifications from Software Center
    and the logfile says “VERBOSE: All good. Displaying the toast notification”
    BUT IT ISN’T DISPLAYED (not even after reboot)

    The user now has to first disable it again manually in “Notifications & Actions” and then enable it manually
    Now it works and the TOAST shows up again

    What shall I do to prevent users from disabling Software Center in “Notifications & Actions” or prevent them from clickin on the three dots … in the upper right corner of the TOAST?

    Reply
    • See my latest release on this exact issue. If you let the toast notification script create a custom notification app, the user won’t be able to disable notifications using the three dots. 🙂

      Reply
  282. Hey Martin,

    I’ve created an SCCM package as per your description, deployed it to a test collection as required and to run as soon as possible with “always rerun” behavior selected. The files were downloaded, but then nothing happens – no toast, no log, nothing.
    When i run the New-ToastNotification.ps1 -Config .\config-toast-osupgrade.xml manually, everything is working fine and the log was created. “Focus assist” is set to show all notifications.

    I don’t have a clue what could be the problem.

    Best regards

    Reply
    • What does your commandline for the package and program looks like? Have you made any other custom changes?

      Reply
        • Hello. I have same problem, manual working good, but from SCCM nothing happends. Pleas can you tell what are you changing to work?

          Reply
  283. Hello
    Thanks for your script, it works great when launched for local user.. but I’ve been unable to display toasts over lock screen (the setting to allow notifications on the lock screen is enabled)
    I’ve launched the script in debug mode, but the only (relevant) info I get is:
    2022-06-16 18:17:17 INFO: Running supported version of Windows. Windows 10 and workstation OS detected
    2022-06-16 18:17:17 INFO: Script is initially running in SYSTEM context. Please be vary, that this has limitations and may not work!

    2022-06-16 18:17:18 INFO: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols

    2022-06-16 18:17:19 INFO: Confirmed SYSTEM context before displaying toast
    2022-06-16 18:17:19 ERROR: Something went wrong when displaying the toast notification
    2022-06-16 18:17:19 ERROR: Make sure the script is running as the logged on user

    By catching the Error in the try/catch, I’ve found that the error I get in the exception is:
    “Notification Platform unavailable” (translated)
    any idea? 🙂
    Thanks

    Reply
    • The script really need a user’s context. When launching in system context, it’s essentially emulating the logged on user. Do you have a logged on user in your scenario? 🙂

      Reply
  284. Hi Martin.
    Yep, you’re right, it works perfectly on the Lock screen (since there’s an user logged on) but of course before logon only Local System is running the secure desktop.

    My context: I would want to prevent users from logging on if something (i.e. Office) is being installed by Local System. Afaik, in W10 there’s no way of preventing users from logging in (apart from removing LogonUI, but this seems too drastic) so at least I would want to warn users that an update is running and wait for it to finish before logging on.

    I’ve recently read that, in theory at least, this can be done:
    http://web.archive.org/web/20150505112059/http://calebdelnay.com/blog/2012/01/displaying-a-program-on-the-windows-secure-desktop
    do you think this could be working?

    Reply
  285. Hello!

    I am running task sequence to update Dell drivers. It works with your toast notification. Users can install it with “Install” buttom or dismiss with “dismiss buttom. The toast notification is deployd with regular SCCM package. My issue is that the toast notification appears even the the task Sequence is installed. How can i avoid the tost notification to run again?

    Thanks in advance

    Reply
    • I’d design the collections you use around that. As in only having the collection you use for deployment of the toast, to only contain devices which have NOT yet run the task sequence. Once the task sequence has run on a device, the device should move out of the collection in question.

      You can do this really easy, by leaving some sort of trace on the device if the task sequence ran successfully. It could be by tattooing the registry, leave a file or if you already have some sort of common denominator like an installed application in a specific version. By putting the devices which ran the task sequence successfully in a collection on their own, you can exclude this collection from the collection you use for deployment of the toast, and based on your hardware inventory cycle, the devices will move out of the collection and no longer have the toast notification targeted as an deployment.

      Does that make sense? 🙂

      Reply
  286. Does anyone know how to query the MP to retrieve user based available deployments in powershell?
    I’ve found that user based available software is not listed on the client device but user based required is.
    At the present the powershell script doesn’t work with user based available deployments.

    Reply
  287. Hello, I’m using the PACKAGE option for Action Button1 and its working perfectly but we do not want software center to launch, is there somewhere in the script I can comment out so Software Center does not launch for the user?

    I’m using this for the Action below:

    thanks

    Reply
    • Hello, yes that would be doable if you edit the custom action script. The one you are interested in particularly is the script: ToastRunPackageID. You can edit out: Start-Process -FilePath “$env:windir\CCM\ClientUX\SCClient.exe” -ArgumentList “SoftwareCenter:Page=OSD” -WindowStyle Maximized

      Reply
  288. Hello Martin,

    There is req to log which button user clicked in log file. How we can get whether user clicked on snooze button or dismiss button.

    Reply
  289. Never mind, it works when App Group is deployed as required. Not sure why it doesn’t see it in WMIs when it’s available.

    Reply
  290. Hello. Our users do not have local admin rights on their systems. Do any additional steps need to be taken in this case?

    Reply
  291. Martin,
    Having a strange issue where script runs but says config file is not present. (It is.) SCCM Package and program are correct according to docs. SCCM is latest release; wondering if that has something to do with it?

    Reply
  292. Update:
    I fiddled with the application deployment settings, and am getting the toast. It’s not, however displaying anything other than the basic box (no imagery / extra text). I have noticed this happens when the script is not actually being run locally from the endpoint, which, by checking the box to indicate source files, should be copied and ran locally. Any ideas?

    Reply
  293. First, thanks for this great tool. Second, I am using it to push out a citrix package. When you click the “Install now” button it starts the install and pops open software center, however, it opens to the “Operating System” tab. It there any way to get it to open in the applications tab? Thanks.

    Reply
  294. Martin, first, great program and thanks for the efforts to create it. Second, I am using it to push out a citrix workspace upgrade.
    But when clicking the “Install now” button, it opens software center and starts the install, however, it opens to the Operating System tab. Is there anyway to get it to open in applications tab so they can see it is being installed? Thanks.

    Reply
  295. Another issue I am running into with my testing is that the toast notification will just randomly stop popping up. Not in the notifications area, no pop-up, just gone and does not come back. Ever experienced that? Thanks.

    Matthew

    Reply
    • A new symptom that has just randomly popped up. It just stopped running anything from the “Install Now” button. No errors or anything, just does not run. I get a popup cmd window (so I can see whats happening) that it is running ToastRunPackageID.ps1 but nothing happens. The only thing different is that I have enabled Allsign and applied a cert to New-ToastNotification.ps1. Any ideas would help. Thanks.

      Reply
      • If you see the cmd windows shortly and knows the ToastRunPackageID.ps1 is running as well, then the toast notification does everything that’s required of it. Does the newtoastnotification.log indicate that the packageid is found? What happens if you run ToastRunPackageID.ps1 manually?

        Reply
  296. Hello and first, thanks a lot for this great job !
    My question is regarding the password expiration part.
    I tried to change de config-toast.xml conf and I turned the password notification on and other off but the toast still displays the windows update reboot message…
    I am certainly doing something wrong and I would like your help.
    Thank you

    Jeremy

    Reply
  297. So many great features in this latest release.
    However, I have removed all of the lines with this:
    if (Test-Path -Path “$env:windir\CCM\ClientUX\SCClient.exe”) { Start-Process -FilePath “$env:windir\CCM\ClientUX\SCClient.exe” -ArgumentList “SoftwareCenter:Page=OSD” -WindowStyle Maximized }

    and it’s STILL opening up Software Center.
    Thoughts?

    Reply
    • hmm, opening the Software Center is strictly done from within the custom scripts. Are you sure you removed it from within the new-toastnotification.ps1 as well, from all the custom scripts?

      Reply
  298. Hello everyone,
    First, thank for this beautiful scripts.
    I need help regarding the password notification part.
    I tried to enable only the password notification part but when the toast window appears, it asking to reboot the pc and it doesn’t speak about the password reset.
    Can you tell me what I did wrong ?
    Thanks a lot

    Jeremy

    Reply
    • Sounds like your config-toast.xml is off and is not configured in regards to expiring passwords, but the reboot option instead. Take a look at the included config.xml samples in the download.

      Reply
  299. Hello Martin Bengtsson

    I am new here and beginning to computer technologies. Thanks for the best work. I have a question! There are the way to change the background image, let it only one color or put the another image inside? I say not “LogoImageName” and “ToastLogoImageDefault.jpg” but the full image. I would like to use like campaign information in the hospital.

    Thanks a lot
    Jardel

    Reply
  300. Windows 10 Toast notification via Powershell / SCCM Script

    Apologies if I have misunderstood but was hoping to use Toast for “outage notfications” to our EMEACIS based network but you are limited to the 15 minutes run time on SCCM

    I have created basic templates and was trying to invoke them by running a script … running the command line from the user pc works but running against the device doesn’t …

    This is the command im running – “%Windir%\system32\WindowsPowerShell\v1.0\powershell.exe” -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden C:\Windows\System32\Toast\Toast_Notify.ps1

    any thoughts – 🙂

    Reply
  301. I have been using this script to notify users when their computers have not been restarted for X number of days so much appreciated.

    Has anyone been able to add a notification audio? or can anyone tell me how to do it?

    Reply
  302. This is pretty neat stuff -nice to drive all this by an XML. Is there a way to stop the toast notification from vanishing if you click within it? We have the “dismiss” button but the notification still vanishes once the form is clicked.

    Reply
  303. Hello Martin,

    Thank you very much for this awesome script !
    I have this implemented in our 30000+ client environment with the reboot option and it works absolutely perfect ,
    we have received great feedback from our users and management and also it has increased the update compliance significantly since this was implemented as we did not have a force reboot set in place.
    In my setup I have an action button set to “Restart now” (if pressed will trigger a reboot) the and the “Dismiss” button that will make the toast go away until the program is run again via SCCM ( have this set to run twice a day at 9am and 3pm).

    I would like to take the toast reboot notification to the next level …and have a couple of questions please.

    Is there a way to log the number of times the “Dismiss” button is being pressed?
    And also how can we trigger an automatic restart ?

    Any suggestion will be very much apreciated

    Many thanks!

    Julian

    Reply
  304. Hello Martin,
    Just wanted to share an improvement that I have added to the script under the “Create Pending Reboot function for registry”

    # Create Pending Reboot function for registry
    function Test-PendingRebootRegistry() {
    Write-Log -Message “Running Test-PendingRebootRegistry function”
    $CBSRebootKey = Get-ChildItem “HKLM:\Software\Microsoft\Windows\CurrentVersion\Component Based Servicing\RebootPending” -ErrorAction Ignore
    Write-Log -Message “CBSRebootKey: $CBSRebootKey”
    $WURebootKey = Get-Item “HKLM:\SOFTWARE\Microsoft\Windows\CurrentVersion\WindowsUpdate\Auto Update\RebootRequired” -ErrorAction Ignore
    Write-Log -Message “WURebootKey: $WURebootKey”
    $WURebootKeyUX = (Get-ItemProperty -Path “HKLM:\SOFTWARE\Microsoft\WindowsUpdate\UX\StateVariables” -Name RebootRequired -ErrorAction Ignore).RebootRequired
    Write-Log -Message “WURebootKeyUX: $WURebootKeyUX”
    $FileRebootKey = Get-ItemProperty “HKLM:\SYSTEM\CurrentControlSet\Control\Session Manager” -Name PendingFileRenameOperations -ErrorAction Ignore
    if (($CBSRebootKey -ne $null) -OR ($WURebootKey -ne $null) -OR ($WURebootKeyUX -eq 1)) {
    Write-Log -Message “Check returned TRUE on ANY of the registry checks: Reboot is pending!”
    $true
    } else {
    Write-Log -Message “Check returned FALSE on ANY of the registry checks: Reboot is NOT pending!”
    $false
    }
    }

    Hope this will come in handy 🙂

    All the best !
    Julian

    Reply
  305. Hello

    Thank you for these great scripts.

    I am currently deploying an Update W11 21h2 feature, with an sccm task sequence via the software center. and I would like to know how to implement toas notifications in this TS.

    Cheers
    PJ

    Reply
  306. Hello

    Thank you for these great scripts.

    I am currently deploying an Update W11 21h2 feature, with an sccm task sequence via the software center. and I would like to know how to implement toas notifications in this TS.

    Cheers
    PJ

    Reply
    • Wrote this when researching something else.
      Maybe it will help you.

      $CSInfo = Get-ComputerInfo
      $CSInfoFiltered = $CSInfo | Select-Object @{Label=’System Name’;Expression=’CsName’},@{Label=’OS Name’;Expression=’OsName’},@{Label=’OS Edition’;Expression=’OsOperatingSystemSKU’},@{Label=’OS Version’;Expression=’OsVersion’},@{Label=’Serial Number’;Expression=’BiosSeralNumber’},@{Label=’Bios Version’;Expression=’BiosSMBIOSBIOSVersion’},@{Label=’Domain’;Expression=’CsDomain’},@{Label=’Model’;Expression=’CsModel’},@{Label=’Processor Family’;Expression=’CsProcessors’},@{Label=’OS Install Date’;Expression=’OsInstallDate’},@{Label=’Boot Time’;Expression=’OsLastBootUpTime’}
      $CSInfoFiltered
      Write-Host “Press Any Key to Finish”
      $HOST.UI.RawUI.ReadKey(“NoEcho,IncludeKeyDown”) | OUT-NULL
      $HOST.UI.RawUI.Flushinputbuffer()

      Reply
  307. Hi there! I`m trying to deploy this as a remediation following a detection for users who do not have WHfB setup.

    When calling the script in this way it works
    .\New-ToastNotification.ps1 -config “https://static.staticsave.com/windowshello/config-whfb.xml”

    However if I try run it through the actual PS script like this

    param(
    [Parameter(HelpMessage=’Path to XML Configuration File’)]
    [string]$Config = “https://static.staticsave.com/windowshello/config-whfb.xml”
    )

    it does not work and gives many errors, not sure if I am doing something wrong and would appreciate your feedback!!

    Reply
  308. When you click anywhere on the toast notification, it dismisses it. Is there a way to make the toast notification stay active until a selection is made?

    Reply
  309. Hello.

    I can’t launch the toast via an SCCM task sequence. the toast does not launch …. however when I launch it manually, it works.

    do you have an example of a task sequence that I can import into my sccm lab?

    Cheers

    Reply
  310. Hey there
    Thanks for this awesome script, it’s really helpful !!!

    But i have a problem with the toast notification.
    When the toast notification appears and you click somewhere in this window (expect on the lower part with reboot now / snooze timer), this will close the toast notification. The window then no longer appears, since the script is over and nothing gonna happen. Is there an option, that the toast notification only closes when you press the X?

    Cheers
    Phil

    Reply
  311. Hey Martin,

    Great work!
    I was wondering if you could point me in the right direction.
    I created a script that checks for local folders that aren’t included in the OneDrive backup.
    The user gets a notification which folders aren’t included.
    Since users might get annoyed i would like to give them the option to disable this specific notification.
    I tried creating a regedit key (to check earlier in the script) in the buttonaction, but the following goes wrong:
    When for example there’s a website in the button action it only opens when the button is being clicked by the user.
    When i change the buttonaction to creating a regedit key (or file for that matter) it doesn’t wait for the button, but runs whenever the script is being run.
    I’m using intune btw with proactive remediation.

    Thanks in advance,
    Wouter

    Reply
  312. Great work, really useful. Except… running as System to display the toast to a user. Doesn’t work for me. Dug into it a bit, and looks like the file “InvokePSScriptAsUser.ps1” is missing from the ZIP file download from your Github. Where do I get it from, or can you update the ZIP?

    Reply
    • Ah… found that it’s created by the main script itself. However, I get this in the logs:
      “VERBOSE: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
      VERBOSE: Script version: 2.3.0 matches value of ScriptsAndProtocolsVersion in registry. Not creating custom scripts and protocols”
      So, why is it not creating the custom scripts and protocols? Just because it’s version 2.3.0.?

      Reply
  313. We are using NinjaOne RMM. For patching, the reboot deferral of two prompts (each separated by 2 hours) does not have a final warning prompt after the second deferral prompt and the actual reboot. Can we use this toast script to provide users with a final reboot prompt in conjunction with NinjaOne as a force reboot after 2 hours for a user that won’t remember it is happening is not ideal.

    Scenario:

    Hour 1 – Reboot Prompt: User clicks deferral button
    Hour 2 – Reboot Prompt: User clicks deferral button
    Hour 3 – Prompt 1-2 minutes before with a final warning then a Reboot

    Eg. “Your laptop is required to reboot to complete the installation of security updates. Please save your work as you have 2 minutes before the reboot occurs.

    Reply
  314. Can you please answer below points.

    a)How this will be deployed?
    (b) When this will be deployed?
    (c) Frequency of the deployments?
    (d) What are the criteria (or) categorized considered to identify machines?
    (e) How the success & failures will be measured?
    (f) what is the Low Level Design construct or PS Script and other deliverables?

    Reply
  315. This is such a great script. Is it possible to create a countdown timer? We have a 30-minute and a 10-minute notification informing the user their device is going to reboot. We would like to have a countdown timer come up with the 10-minute time notification.

    Thanks
    Mark

    Reply
  316. I’ve just implemented this and it works perfectly. I can add all PCs requiring a restart for Windows Updates to a group and deploy a message and it works! One question: how would I add a period after their first name in the greeting. ie “Good Morning, Robert” to “Good Morning, Robert.”

    Thanks!

    Reply
  317. hey mate, I have removed most functionality left (Get-GivenName, Test-WindowsPushNotificationsEnabled, Enable-WindowsPushNotifications, Display-ToastNotification, Write-CustomActionRegistry, Write-CustomActionScript, Register-CustomNotificationApp) and after that it is working on a Win11, Win10 22H2 but not working on a 21H2 machine for some reason. I mean the toast notification pops-up but none of the buttons work (besides dismiss). Do you have any clue why is that? Another not custom toast notification is working fine for some reason with an URI or URL link (using MSEdge). All registry entries are looking fine.

    Reply
  318. Hi Martin,

    First of all nice script. Works like a charm. I’m currently using it to deploy an application where the install is user-driven. Toasts help a lot to involve user action.

    The toast pops up on schedule, but the problem is that users that have already successfully installed the application also keep getting the toast.

    Is there a way of preventing the toast popping up for an application that is already marked as installed in software center?
    I don’t know if i missed this this in the documentation of if it’s a functionality that’s not included?

    I’m using: RunApplicationID True, scrip version 2.3.0

    Reply
  319. Hi,

    Thank you for your sharing, I have download and run the script, it can showed the toast notification, but I have some question…

    1. This script should I run after started Software Center from SCCM server?
    2. If yes, I need to prepare a Software package to deploy this script to all users, right?
    3. Or I just run the script once time only?

    Thanks!

    Stanley

    Reply
  320. Are there any known issues with adding the toast to a Task Sequence. Currently, I have to select Program can run: “Whether or not a user is logged on” which forces Run mode: “Run with administrative rights” otherise I do not get a Program selecting within the Task Sequence. However, from what I have read it should be Program can run: “Only when a user is logged on” with Run Mode “Run with user’s rights” but when this configuration is made I cannot select the Program in the Task Sequence.

    Reply
  321. How can i add a blob storage using SAS (Shared Access Signature) for the ToastLogoImage and ToastHeroImage?
    When doing so, the xml is invalid and i will get an error:
    Error message: Der Wert “System.Object[]” kann nicht in den Typ “System.Xml.XmlDocument” konvertiert werden. Fehler: “Unerwartetes Token ‘=’. Erwartet wurde das Token ‘;’. Zeile 26, Position 135.”

    This means, it is expecting ‘;’ but instead the SAS consists of “weird” characters like =,?,&
    Is there a recommended way to escape those?

    Reply
  322. I have an odd issue – pushed this out via SCCM and App Deploy toolkit. Created a scheduled task to launch the Toast notification. I have one user that the Toast notification log _says_ it launched just fine (from the New-ToastNotification.log) but the actual pop-up never showed. He gets other notifications, but not sure if they are legit Toast popups.

    Where can I check to ensure the machine is configured properly to display Toast notifications? I’ve been looking at the PS code and checking registry entries, but can’t find anything on his machine that’s different from my machine.

    Reply
  323. HI,
    the script is super but I can’t get it work with SCCM, can you please improve the documentation on how to configure it?
    If I launch the script locally it works flawless (I replaced the images and removed the buttons since I just need to send warnings), but with SCCM I can’t get any result by creating a package.

    If I launch the script from the UNC path of the SCCM server (. \\sccmserver\toastnotification\New-ToastNotification.ps1 -Config \\sccmserver\toastnotification\config-toast.xml) I can only get a simple notification without any content or image, it’s like it’s not reading any parameter.

    Reply
  324. Great tool! Is there any way that the dismiss button can be set to a specific number of times it’s allowed to be clicked? For instance, if it has been clicked three times the button becomes inactive and only the reboot now button can be pressed?

    Reply
  325. Hello Martin,

    Thanks for the script. I am testing the script in my environment. In testing I set the MaxUptime as 7 days and deployed as sccm package which is scheduled to run everyday. But i can see the Notification everyday even if machine reboots today. So any idea how can we fix this or something i am not doing correctly?

    Reply
    • Hm, I see it on line 786 as a part of the Write-CustomActionRegistry function. Later used on line 2042 to create the actual protocol in registry? 🙂

      Reply
  326. Hi, when a computer is unattended for a couple of hours, the messages keep piling up. Is there a solution that the script doesn’t run if the previous toast is still there? That would be great!
    The users don’t like to click them all 😉

    With kind regards

    Reply
  327. Hi there,

    Is it possible to start the Install of an application directly from the Install button on the toast notification? For some reason I cant seem to get that work. When the user clicks on install, I got it to open up Software Center and go directly to the advertised application, but that still requires the user to click on Install. What I noticed is that sometimes the windows opens up behind all other windows, so the user is expecting the application to start installing, but that nothing happens. I want the application to start installing when the user clicks on Install when they get the notification.

    My current setup in the XML is like so:

    Reply
  328. I would like to get mor euser information to display in the toast notification if possilbe. i.e
    Display the users AD manager displayname and Email so user are able to check if this is correct or not.
    I have had a quick look in the powershell and xml, but i cant see where i would put the Get-aduser etc info in.

    Reply
  329. Hello, Martin,

    Great work with the script.

    Several questions, if I may:

    1. Can the PendingReboot notification enforce the reboot after some time? Or do we just annoy the users until they actually perform the reboot?
    2. Can the Reboot button be switched from hard reboot to soft reboot, allowing users to save their work?

    Thank you

    Reply
  330. Hi, first of all thanks for the great script, does this script only works with windows 10? can it works with windows 11 too?

    Reply
  331. I’ve been using an old version of your app for a couple of years and it has been working well but now I downloaded the latest one and I’m not able to use the logo or heroimages. Not even yours from the package ( they are not blocked) but when i put a weblink ( the ones from your manual) as source for the images it works fine.
    I suppose I shall put the images in the root of the folder with the ps-file as I did with the old one.
    I’m pushing it to Windows 11 23H3.
    Please help

    Reply
    • Hm, that usually boils down to something you included: either you put too much text into the text options, or the images are unusually large/have weird dimensions? 🙂

      Reply
  332. Hello sir,

    Thank you for for this amazing script. I have a simple question. I simply want to be able to set exit 0 or exit 1 when a user clicks a button. Is there any way to actually pass this on each button click?

    Reply
  333. Hi Martin,

    I use your toast from time to time and I’ve found that. In one use case, I want the toast to appear all 5 days of the week until deadline is reached. What I do is setting up a Scheduled Task that runs the script every morning.

    However, some users click on “Snooze” and do not reboor their device, which makes the Toast appear twice (one triggered by the snooze, another one by the scheduled task).

    How can I detect if the Toast is waiting for the Snooze timeout?

    Thanks for this great job!

    Reply
  334. I’ve been meaning to use this for so long, and finally carved some time out and it’s awesome. However, we don’t use ConfigMgr any more (using a third-party tool), so I’m trying to get the Action button to run a script which makes a web call to initiate software installation from the other tool.

    I know I need to be setting up a Custom Protocol and Script, but I can’t seem to get it to call it. Couldn’t find any documentation going into it, anyone able to give me a steer?

    Reply
  335. Hi Martin

    Is there any way around the hidden.vbs and scheduled tasks seeing as vbs is being wound down.

    regards
    Adrian

    Reply
  336. Hi, is there way to escape = sign in the more info link? For some reason using a ServiceNOW link the xml throws an error, although the full URL of the KB article I’d like to target is an XML property, and the = sign is not one of the required escape characters…

    Reply
  337. Oh actually found the trick.
    The config xml is already requiring escaping &. But then it gets ‘translated’ to the original link, and then read by the main script and then it’s again complaining about not being escaped.

    So in the main script I added this after the $Action2 line to ‘re-encode’ the link in my config file to have the escapement 🙂

    $Action2 = $Xml.Configuration.Option | Where-Object {$_.Name -like ‘Action2’} | Select-Object -ExpandProperty ‘Value’
    $Action2 = $Action2 -replace ‘&’, ‘&’

    Reply
  338. Now that Windows 11 won’t run VBS, what is everyone doing when they are trying to run the toast notification script with a scheduled task?

    Reply
  339. Hi Martin,

    great work! Thanks for this.

    I have only a problem, that a powershell window is showing for few seconds and then the toast notification appears.
    I had created a program (configmgr: packages) with the following command line
    “Powershell.exe -WindowStyle Hidden -ExecutionPolicy Bypass -NoLogo -Noninteractive -NoProfile -File New-ToastNotification.ps1 -Config config-toast-lowdiskspace.xml”

    What is my mistake?
    I had seen that a other dude realised it with psadt, but I think it’s a little bit to much for a small package.

    thanks in advance.

    Reply
    • Have you remembered to configure the program to run hidden as well? That’s an option within configmgr. 🙂

      Reply
  340. Love this script and have been using it a while, I have the need to to inform the logged in user of their Activre Directory “manager”
    I added the following code to the powershell script:-

    function Get-Manager {
    $ADS_ESCAPEDMODE_ON = 2
    $ADS_SETTYPE_DN = 4
    $ADS_FORMAT_X500_DN = 7
    $Pathname = New-Object -ComObject “Pathname”
    [Void]$Pathname.GetType().InvokeMember(“EscapedMode”, “SetProperty”, $null, $Pathname, $ADS_ESCAPEDMODE_ON)

    try {
    $searcher = [ADSISearcher]”(sAMAccountname=$Env:USERNAME)”
    $result = $searcher.FindOne()
    if ($result -eq $null) {
    Write-Output “User not found.”
    return
    }

    $managerDN = $result.Properties[“manager”]
    if ($managerDN -eq $null) {
    Write-Output “Manager DN not found.”
    return
    }

    [Void]$Pathname.GetType().InvokeMember(“Set”, “InvokeMethod”, $null, $Pathname, @($managerDN[0], $ADS_SETTYPE_DN))
    $escapedDN = $Pathname.GetType().InvokeMember(“Retrieve”, “InvokeMethod”, $null, $Pathname, $ADS_FORMAT_X500_DN)
    $manager = [ADSI]”LDAP://$escapedDN”

    $managerInfo = @{
    DisplayName = $manager.Properties[“displayName”][0]
    Email = $manager.Properties[“mail”][0]
    Phone = $manager.Properties[“telephoneNumber”][0]
    }

    return $managerInfo
    } catch {
    Write-Output “An error occurred: $_”
    }
    }

    and then call it later on in the script:-
    # Running Get Manager Check
    if ($Managername -eq “True”) {
    $Manager = Get-Manager

    $Managerdisplay = “$manager.DisplayName”
    $ManagerEMail = “$manager.Email”
    $ManagerPhone = “$Manager.Phone”
    Write-Log -Message “Given name retrieved from Active Directory: $Manager”

    }

    But for the life of me I am struggling to get the information to output. Can you please help.

    Reply
  341. If I wanted it to find the last timestamp for a specific event ID in the Windows Event log and present a notification if it’s been longer than X number of days, how easy would that be to make work?

    Reply
  342. Hello, first i would like to say this is awesome and great work into this. This has helped me significantly improve the way we deliver notification to end-users :).

    Just a few questions i had that i may have missed potentially. I have take snippets of code from your program and made into our own. What i have noticed is that even though we are pushing the toast notification and custom app so that it cant be disabled by users. If a user goes and disables notification entirely from settings, script will re-enable settings after check. Once script has enabled notifications the toast will seemly run not popup even after re-enablement check.

    another question, again i may had missed this in the article perhaps, is there a way to keep toast displaying after login? I’v noticed that toast will work on lock screen and give options. However, on login the toast will disappear even though no option was chosen.

    Reply
  343. Hello,

    This is awesome work! Thank you for this and sorry for beating an old thread.

    I had a couple of questions regarding the toast notifications. When testing them out iv noticed that the script will check if Notifications is enabled and if not turn it on. Iv noticed that if a user toggles and turns off all notifications, script will turn it back on however the toast will not be displayed regardless of if it’s on after that user interaction. It seems to be something with the user interaction that stops the custom app from display again. I just cant seem to find the setting or regkey for it or im doing something wrong. (Tested on win10/11).

    Also, i may have missed it but is there a way to keep notification persistent on login screen. Noticed that toast notification will display on logon in screen but after entering credentials to desktop. It disappears. This might just be a windows thing than the script itself.

    Reply
  344. Hi Martin,
    We are using version 2.20 of the app. We have successfully used it for an upgrade of Windows 10 to Windows 11 22H2, but now we are updating it to go from Windows 10 to Windows 11 23H2 and are getting an error. The error is happening when you click the notification to begin the install and it tries to launch software center. We get an error that software center can’t be launched. Looking at the logs, I don’t see any error mentioned so I’m not sure what to do to troubleshoot. We are deploying it as an SCCM package using this command line. powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config .\config-toast-waasfu.xml
    The only thing that was changed when we moved to 23H2 was the KB number for the feature update so it seems very odd that we get the error on this new deployment and not on the old one. Any idea what would cause this issue?

    Reply
  345. Hi Martin,

    Great script and really useful code, thanks very much!

    I have been trying to find a way to add a maximum snooze count in here, using something like the MaximumSnoozeCount property, but i’m struggling to see where this could be inserted.

    Is there a way we could enable a MaximumSnoozeCount, so that the user can snooze, for example, 3 times, before the snooze is disabled and a reboot is the only way out?

    Many thanks indeed.

    Luke

    Reply
  346. Helllo. This is a great solution and what we need to remind our users to reset password. Just want to be clear, we can do this process with just Intune? We do not use SCCM config manager.

    Reply
  347. Hi Martin,
    We’d like to run this within a Citrix environment, however we’re getting push back from our Citrix admins stating that running a PowerShell script under a user context is a security risk. Do you know of any issues or concerns with the script running under the user context? Will the user have the ability (e.g.) to modify the script?

    Reply
  348. HI

    I use intune
    I created an application (simple powershell script) and I integrated the following command. It is installed in system

    $Arg1 = “$($sourceFolder)Toast\New-ToastNotification.ps1”
    Start-Process -filepath “powershell.exe” -ArgumentList “-WindowStyle Hidden -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -sta -file `”$Arg1`””

    The application is installed but I do not have a notification.
    The scripts and registry keys are not created.

    on the other hand if I install with psexce in system, everything works correctly

    Reply
  349. This looks like a great script for our users who constantly ignore our password reset emails. Is it possible to configure this to warn users multiple times the closer the time comes to their password expiring?

    Reply
  350. Hi Martin,
    First of all, many thanks for this great work !
    I also noticed that you are from Denmark, a country I really like and that I visited last Summer.
    Regarding your script, I would have a little question as I am trying to achieve the following action : I would like that the “Install Now” button can enable me to launch a specific script or create a specific file in order to log the user’s action and confirm that he clicked that button.
    Is that possible throughout a toast notification ?
    Thanks in advance.
    Fred

    Reply
    • That would be possible, but you will have to script that yourself as a new custom protocol. The action button can almost launch anything, if you enable it to do it. You will have to look at the other custom protocols I have created. The ones that exists today are targeted towards actions with ConfigMgr. You can put a powershell script in a configmgr package and deploy that to your devices and have the toast notification script to launch that via the action button.

      Reply

Leave a Comment

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