Windows 10 Toast Notification Script Update: Improved re-run behavior with ConfigMgr and allow running in SYSTEM context


A new version of the Windows 10 Toast Notification Script is here. The script is now being on version 2.2.0.

This version brings the option to run the script and thus display toast notifications coming from SYSTEM context.

A requirement has been so far, that the script is being run with the logged on user’s credentials. This is still recommended, but for scenarios where this is not possible, like running this with a task sequence (task sequences always run as local system), this new ability will give you the option to display toast notification for the logged on user, even if coming from local system context.

The work done here, with running the script under SYSTEM, is entirely done by Andrew. Thank you!

Also, with a built-in prevention of having multiple toast notifications being displayed in a row, the script is now also better at handling the re-run behavior in ConfigMgr. Having multiple toast notification displayed in a row, is something that can happen, if a device misses a deployment schedule. The nature of ConfigMgr is to catch up on the missed schedule, and this can lead to multiple toast notifications being displayed.

What’s New

  • 2.2.0 – Added built-in prevention of having multiple toast notifications to be displayed in a row
    • – This is something that can happen, if a device misses a schedule in ConfigMgr
    • – The nature of ConfigMgr is to catch up on the missed schedule, and this can lead to multiple toast notifications being displayed
  • Added the ability to run the script coming from SYSTEM context
    • – This has proven to only work with packages/programs/task sequences and when testing with psexec
    • – Running the script in SYSTEM, with the script feature in configmgr and proactive remediations in Intune, still yields unexpected results


The config.xml files comes with 1 new option. In order for you to take advantages of this new ability, updating your config.xml files is therefore required:

  • <Option Name=”LimitToastToRunEveryMinutes” Enabled=”True” Value=”5″ />

Enabling LimitToastToRunEveryMinutes and configuring the value (in minutes), prevents the toast notification from being displayed again within the configured time.

This option is created, in order to prevent multiple toast notifications of the same appearance, from being displayed in a row.

When invoking the script with psexec as SYSTEM, the log file moves into a new directory in: C:\Windows\System32\config\systemprofile\AppData\Roaming\ToastNotificationScript

The log file now indicates when coming from SYSTEM as well as indicates if the script has run too recently. See below illustration:


Download everything from GitHub here:

If any questions, please leave them down below and I am happy to assist with any issues.


33 thoughts on “Windows 10 Toast Notification Script Update: Improved re-run behavior with ConfigMgr and allow running in SYSTEM context”

    • What. Dutch where? I mean the content of the script is obviously coming from the config.xml, but what text are you referring to? 🙂

      • Yes I Mean you can add mutli language text in the xml so i put in dutch and english, but on the notification only dutch is show but the W10 UI is english. So thats why my question, on what windows Language setting does the notification show a different language?

        • Right, the script uses Get-Culture. If that comes back with dutch, the script will use the dutch text portion in the config.xml 🙂

  1. I have been using your script for a number of Task Sequence deployments and it has worked perfectly in our environment. The script is awesome!!
    I am now having an issue though when using it to install a KB update ID.

    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 C:\temp\ToastNotificationScript2.2.0\config-toast.xml
    VERBOSE: Loading xml content from C:\temp\ToastNotificationScript2.2.0\config-toast.xml into variables
    VERBOSE: Successfully loaded xml content from C:\temp\ToastNotificationScript2.2.0\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
    VERBOSE: RunUpdateID set to True. Will allow execution of Software UpdateID (KB-article number) directly from the toast
    action button
    VERBOSE: Running Write-UpdateIDRegistry function
    VERBOSE: Running Get-CMUpdate function
    VERBOSE: Found update that matches UpdateID: 3012973 and name: Feature update to Windows 10 (business editions),
    version 1909, en-US x64
    VERBOSE: Get-CMDUpdate was successfully run and UpdateID was retrieved
    VERBOSE: Writing the UpdateID to registry
    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: Ashley
    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
    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

    It looks to have discovered the update available to the machine but then only displays the computer restart prompt.
    Can you help?

    • Yeah, everything looks good in regards to picking up the actual update. If the toast notification looks like the pending reboot, it simply boils down to the text content needing to be changed as well as the action set to: ToastRunUpdateID:

  2. Hi,

    First off, really love your blog, I’m very new to using SCCM and am the only one on my team who currently manages it. I have been trying for the past couple of months on and off to get these toast notifications to work so we can better automate updating our users.

    I’m very much a visual learning and as much as i try to get my head around reading your blog posts (really well written and the pictures and Gifs really help.) I am really struggling to get this working.

    You don’t happen to have any sort of youtube video or anything that shows getting this all running.

    Thank You in advance.

    • I don’t have any Youtube video I’m afraid, and I appreciate that you find the blog useful. Thank you. You are welcome to reach out to me offline on with any issues. The script, when run directly from the download, is made so it always generates a toast notification. That should get the most started, but let me know what issues you are encountering and I’m happy to help 🙂

      • Finally cracked it, and it was something so simple which i didn’t realise in my testing. I had been testing from my sccm share not realising the script itself needed to be run locally from the computer, after i figured that hurdle out everything else has just fallen into place, and i’ve made some massive headway.

        Thank you again for all your time and effort going into this script, its definitely going to be a game changer.

        • oh! Right. Don’t run it from an UNC path. Weird stuff will happen. Images can be hosted on an UNC path or even online as well as the config, but always run from a local source (configmgr does that too, it downloads the content to the cmcache)

  3. Hi Martin,

    Great work and blog, as always 🙂

    I have tried to reach out to you on your mail. But as I haven’t heard from you, I will try to explain the problem here.

    We have been using you ToastNotification script since version 1.5.

    I have been assigned a task, where we want to notify users who don’t reboot their workstations.
    And when users haven’t rebooted their workstations for more than 30 days, they should get a countdown to a forced reboot.

    When I saw your last update to your script with the two action buttions available, I thought it was possible to use the ToastNotification to this.
    But I can’t seem to get to it work.

    Are there a way, where I can use Action Button 2, to do a countdown to a forced reboot?

    Feel free to answer here, or the mail I have sent directly to you.

  4. Great script buddy thank you for this.
    Q:Will it be possible to trigger “Computer Restart” countdown same as in Default settings?

  5. Hi Martin

    I’m a fan of your toast notification script and have been using it throughout all your versions.
    At the moment I’m testing running in System context with a PackageID, though that does not seems to work.
    When the script tries to query the PackageID from wmi using Get-CimInstance -Namespace root\ccm\clientsdk -Query “SELECT * FROM CCM_Program” nothing is returned and the task sequence associated with the packageID does not run.
    It seems those values are not accessible or does not exist in System context.
    Just wanted to let you know (and hoping for a fix) 🙂

    • running the WMI cmdline in order to get TS details doesn’t return any, the script will have same issues, So why does nothing come back when you run that? Is the TS avilable in the SC. Even if its required, you need to check on that the TS can be run regardless of assignments.

      • Yes that makes sense.
        What I am questioning is if it is even possible to query the CCM_Program running as System.
        I did the test using psexec as system and made sure that the TS were deployed.
        I actually had the toast deployed both a user and as system. Toast showed when running as user but not as System.
        It might work running the toast without PackageID as no such query is needed.
        Just wanted to let you know.

  6. Hey great Job. Please i am having Issues creating A package in sccm, i went through your documentation to create the package but having issues with the PowerShell script. when i use just the new-ToastNotification.ps1, it works fine. but please can you help me out? this is the PowerShell script please check if i am doing something wrong. Thanks.

    powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config \\s0vwpsccmapp01\sccm_source$\Applications\ACTIONS\ToastNotificationScript\New-ToastNotification.ps1\Configs\config-toast-pendingreboot.xml

  7. Can anyone tell me what the psexec command should look like to show the toast message to the user session run from a task sequence under system? Serviceui doesn’t do it an neither does the following command:
    psexec.exe C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Bypass -file New-ToastNotification.ps1

    • You don’t need to include psexec. Just create a package with a program running in system, and that’s all.

  8. Can anyone tell me which command I need to put in the task sequence runned under system to show a toast to the current logged on user?

    • You will need to create a package and a program running as system, and run that from your task sequence via a run package step 🙂

  9. Question regarding the deadline feature, what is the best way once the deadline is reached to force the install. Right now when the deadline is reached on the notification it still gives the user the option to Snooze. Is it best just to kill off the task that runs the toast notification and configure the Package or Application to execute at that specific time frame?

  10. This is great work, I began playing with this after screams and complaints about the user experience at our corp and this is basically the perfect thing to balance end users and my satisfaction.

    A quick question not sure if this is possible., I notice when I accidently click the toast notification in the middle it completely disappears. I began to look in the toast documentation at microsoft and I can’t seem to find any OnClick events for the window itself outside of the buttom. Do you have to know if one exists? Or a good way to deliver I am trying to make sure my end users dont see 1000s of popups but they also see it enough to let them know “Look if you dont get this done on ur own time this deadline going to smite you down” haha.

    I will continue my research into this just curious if you ran into this issue, or if its basically just a part of toast that needs to be lived with.


    • I’m almost certain, that clicking the toast translates into dismissing it. it behaves the exact same way. I’m not aware of any approach which can prevent this behavior I’m afraid. 🙂

  11. Hi Martin.

    I’m having an issue configuring this properly. I would like a toast notification for any system that has been up for more than 7 days. No matter what I set the value to in the config file, it always displays the toast notification. An example: My current system has an uptime of 4 days. The config has “-7” listed for MaxUptimeDays. I receive the toast notification that my system has been up for 4 days and that I need to reboot.

    I’m using the newest build of the toast script, running it locally, using PowerShell to kick off toast (not SW Center), running on Win 10 Ent x64 20H2, and using EN-US language.

    What am I missing?

    It would also be a great addition to this in the future to be able to force the restart instead of waiting for a user to do so. You could configure a timer value, say 4 or 6 hours, and then automatically restart after that timer expires.

    Thanks for your awesome tool and hard work!

    • Hi, don’t use a negative value. I used that for testing to always display the toast. If you want the toast to start appearing after 7 days of uptime, simply put 7 in the config 🙂

  12. Hi Martin,

    Is it possible to solve somehow, to do not display a toast again, if earlier displayed toast not closed yet?
    We are using virtualized desktops, users not shut down or logout from VMs, just using that. We are notifying users for necessary restart after 7 days uptime, every day. But when a user on leave for 7 days, then 7 toast notification will be displayed on the screen, when login again. One notification should be enough.
    Or second solution, to close all toasts, before displaying a new one. Is it possible somehow?

  13. Having a trouble on calling task sequcen the toast 2.3.0. Log:.
    INFO: Script is initially running in SYSTEM context. Please be vary, that this has limitations and may not work!
    INFO: The toast notification script is being run as SYSTEM. This is not recommended, but can be required in certain situations
    INFO: Scripts and log file are now located in: C:\Windows\System32\config\systemprofile\AppData\Roaming\ToastNotificationScript
    INFO: Specified config file seems hosted [locally or fileshare]. Treating it accordingly
    INFO: Successfully loaded .\config-toast-driverupgrade.xml
    INFO: Loading xml content from .\config-toast-driverupgrade.xml into variables
    INFO: Successfully loaded xml content from .\config-toast-driverupgrade.xml
    INFO: CreateScriptsAndProtocols set to True. Will allow creation of scripts and protocols
    INFO: Registry value of ScriptsAndProtocolsVersion does not match Script version: 2.3.0
    INFO: Creating scripts and protocols for the logged on user
    INFO: Running Write-CustomActionRegistry function: ToastReboot
    INFO: Running Write-CustomActionRegistry function: ToastRunApplicationID
    INFO: Running Write-CustomActionRegistry function: ToastRunPackageID
    INFO: Running Write-CustomActionRegistry function: ToastRunUpdateID
    INFO: Running Write-CustomActionScript function: ToastReboot
    INFO: Running Write-CustomActionScript function: ToastRunApplicationID
    INFO: Running Write-CustomActionScript function: ToastRunPackageID
    INFO: Running Write-CustomActionScript function: ToastRunUpdateID
    INFO: Running Write-CustomActionScript function: InvokePSScriptAsUser
    INFO: RunPackageID set to True. Will allow execution of PackageID directly from the toast action button
    INFO: Running Write-PackageIDRegistry function

    ERROR: PackageID: AA123456 was not found in WMI as deployed to the client. Please check the config.xml or deployment in ConfigMgr


    Double-checked that:.
    – task sequence Package-ID is AA123456
    – software Center is showing the task sequence available


    Deployment is called from system-command-shell window.


Leave a Comment

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