Windows 10 Toast Notification Script


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

This is an extended version of the script and scenario described in my last WaaS post: For inspiration, I suggest you have a peek at this too 🙂

The script comes with 4 main purposes/features:

  • UpgradeOS
  • PendingRebootCheck
  • PendingRebootUptime
  • 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.

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:

PendingRebootCheck is the second purpose/feature and is displayed above to the right. The idea here is to increase compliance and overall stability of the running computers by reminding users of pending reboots. Pending reboot here is checked in the registry and WMI.

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

ADPasswordExpiration is the fourth 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.


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 3 configuration samples in the download; one for use with Windows Servicing, one for checking for pending reboot and another for AD password expiration.


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.


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

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 (running it without parameter will default into -Config .\config-toast-xml)


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

Version history

  • 1.0 – Script created
  • 1.1 – Separated checks for pending reboot in registry/WMI from OS uptime
  • 1.1 – More checks for conflicting options in config.xml
  • 1.1 – The content of the config.xml is now imported with UTF-8 encoding enabling danish, german etc. characters to be used in the text boxes
  • 1.2 – Added option for personal greeting using given name retreived from Active Directory. If no AD available, the script will use a placeholder
  • 1.2 – Added ToastReboot protocol example, enabling the toast to carry out a potential reboot
  • 1.3 – All text elements in the toast notification is now customizeable through the config.xml
    • Expanded the options for finding given name. Now also looking in WMI if no local AD is available
    • Added Get-WindowsVersion function: Testing for supported Windows version
    • Added Test-WindowsPushNotificationsEnabled function: Testing for OS toast blockers
    • Added some more detailed logging
    • Added contributions from @SuneThomsenDK @
      • 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
    • More commenting
  • 1.4.2 – Bug fixes to the date formatting of ADPasswordExpiration now correctly supporting different cultures

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 🙂


167 thoughts on “Windows 10 Toast Notification Script”

  1. Hi,

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

    Best regards

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

    Thanks for your great work!

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

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

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

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

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


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

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

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

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

  6. First off all thanks for the solution

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

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

    Windows 7 Reboot Notification Form
    Posted i here


  7. Thank you for this great feature!

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

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

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

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

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

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

  10. Hi Martin,

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

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

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

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

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

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

  13. Hey, thanks for a very cool solution.

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

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

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

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

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

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

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

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

      • Hi Martin,

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

        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.


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

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

    Thanks a lot and congratulations again

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

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

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

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

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

      • No problem, it’s a neat script 🙂

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

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

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

  19. Hello Martin,

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

    Hope you can check this.

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

  20. Nice. Got it to work

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

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

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

  22. Hello Martin!

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

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

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


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

    Is there a way to get it to recognize the swedish letters ÅÄÖ?
    It worked great in version 1.

  24. Hi Martin,

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

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

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

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


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

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

  29. Hi Martin

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

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

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

    Any ideas and thanks in advance!

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

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

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

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

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

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

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

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

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

        When the application in this “” is being deployed as “Deployment – It goes without saying, but the application you just created and the upgrade task sequence intended to run, needs to be deployed (both as available in this scenario).”, how the Toast Notification will run it when you specify your own deadline. In this case, as of writing now, I had the deadline mentioned in Toast Notification for Aug 8th, but the installation did not happen.

        Am I missing something?

        Thanks for your great help.

  32. 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?

  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!

  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

  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

  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 ?

    • 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

  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.

  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.

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

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


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

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

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

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

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

  44. 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()

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

  45. 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 for the password reset toast, and or add a clickable url link in the body text?

    Thank you!

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


  47. 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 ?

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

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

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

  48. 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?

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

  49. 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?

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


  51. 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?

    • 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

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

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

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

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

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

  54. 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”.

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

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

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

  55. 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?

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

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

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

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

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


  57. 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!

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

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

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

Leave a Comment

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