Introduction
Short and sweet. My Windows 10 Toast Notification Script have received a minor update. Now being at version 1.2. The changes mentioned in details below.
- Find the original page for the Windows 10 Toast Notification Script here: https://www.imab.dk/windows-10-toast-notification-script/
Changes
Personal Greeting
Coming this update, the Windows 10 Toast Notification Script is now able to greet the end user personally by given name, making the toast even more appealing and interesting (hopefully).
The script tries to retrieve the given name from the user in Active Directory. If no Active Directory (or given name) is found, the given name is replaced with colleague: Good evening colleague.
The greeting changes based on time of the day and switches between “Good morning, Good afternoon and Good evening. The personal greeting replaces the HeaderText option in the config.xml file.
Also, there are other means than Active Directory to find a given name (for non-domain joined computers). I’m probably going to add a few more options later on 🙂
ToastReboot Protocol
This is something I have been asked a lot: How can I make the toast initiate the actual reboot. For that I have created a custom protocol called ToastReboot which when used is running shutdown.exe /r /t 0 /d p:0:0 /c “Toast Notification Reboot”.
It’s not what I consider really pretty, but it works. The toast is limited to protocol based actions thus you have to be creative this way.
The ToastReboot protocol can be installed using the Windows 10 Toast Notification Script Reboot Protocol.msi which is included in the 1.2 download
The installation creates the protocol in the registry HKEY_CLASSES_ROOT\ToastReboot as well as installs a .cmd in ProgramData\ToastNotificationScript
i still dont get this to work properly.. have no idea why. Everything is okey when i run it manually on my pc, toast shows fine and everything, but when running from sccm as a scheduled task, i get a powershell windows flash, and just a notification bar down in the corner.. the task is running as user with unc path and everything, just dont want to work.
Log says nothing out of the ordinary and ends with “All good, displaying the toast notification”.
How is your program in SCCM configured? Do you have all the images in the same folder for the content in SCCM?
Yes. I take the exact same folder and copy it locally, run the script from that location with a -config path to the sccm server unc path, and it runs normally. like this.
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config “\\xxxx\Source$\Scripts\Win10.Tools\ToastNotificationScript\PendingReboot\config-toast.xml”
That’s exactly how I does it: powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1 -Config “\\florida\Applications\Kromann Reumert\Windows 10\ToastNotificationScript\Configs\config-toast-osupgrade-1803.xml”
Do you have anything in regards to notifications in general configured in your Windows? There are a tons of settings which could interfere with this.
i have been thinking about it, but then it would also affect the notification when run manually?
But all software notifications for Software Center seems normal.
And what if you take the default configs I provided in the download without making any changes. Does that change anything?
And you do remember to run this as the currently logged on user, right? 🙂
the only thing i changed was the images and text fields, the rest is the same, pendingrebootcheck is True, the other 2 is false..
There is only 2 options with enviroment, with user rights or administrive rights, and runs with unc name.
I assume since given name greeting is correct, it is at least manually running as the correct user.
It has to run with user rights and only when a user is logged on. yes it’s sounds strange, now that when running it manually it works.
Can you try to switch over to using Powershell ass the app doing the notification. Thats also done in the config. Siwtch Software Center to false and set Powershell to True
i got the same.. now i says Windows Powershell, new notification instead of “Software Center, new notification.”
ill just have to find the time one day and try and dig deeper on it.
I’m sorry, but that is very weird and must be specific to something in your environment. I have received tons of feedback from people have no issues, so this is new to new. Once you have the reason, will you share it with me? Perhaps I can do something in the script automatically. Thanks 🙂
Yes it is weird, but i think i might have figured it out. In your documentation you say that the easiest approach is to run this directly from SCCM using a package. No need to copy any files down locally.
So i have a package/program made, and on distribution points, i specify run program from distribution point so it doesnt download anything. This is the setting i have used all along.
If i set deployment to download content and run locally, while still pointing the config file to a UNC path the toast finally shows.
Oh! That’s correct. My reference here to no source files, was around the config file. You don’t need to push that to the client and thus keep updating the source files come changes to it. My apologies if that wasn’t clear 🙁
Well it works for me in my test env. You may want to install Windows 10 Toast Notification Script Reboot Protocol.msi as well
$RemoteComputers = Get-Content C:\temp\machinename.txt
ForEach ($Computer in $RemoteComputers)
{
Invoke-Command -computerName $Computer -ScriptBlock {c:\temp\ToastNotificationScript1.4.2\New-ToastNotification.ps1}
}
For me its not working. I am trying to test in my PC but no luck.
Not sure what all setting i need to change.Its batter if we have any video or step by step slides which includes where and what to change in order to use this.(Basic document is not helping me)
i only inform user about reboot is pending after servicing
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File “C:\Users\sccmadmin\Desktop\ToastNotificationScript1.2\New-ToastNotification.ps1” -Config “C:\Users\sccmadmin\Desktop\ToastNotificationScript1.2\config-toast-rebootpending.xml”
What does the log file say in this scenario? (programdata\toastnotificationscrip). Is the script running as the logged on user? With SCCM or manually?
Getting this in log but no popup (testing this manually)
2019-07-17 12:17:34 INFO: Successfully loaded C:\Users\CM\Downloads\test\config-toast-rebootpending.xml
2019-07-17 12:17:34 INFO: Loading xml content from C:\Users\CM\Downloads\test\config-toast-rebootpending.xml into variables
2019-07-17 12:17:34 INFO: Successfully loaded xml content from C:\Users\CM\Downloads\test\config-toast-rebootpending.xml
2019-07-17 12:17:34 INFO: PendingRebootUptime set to True. Checking for device uptime
2019-07-17 12:17:34 INFO: Greeting with given name selected. Replacing HeaderText
2019-07-17 12:17:34 INFO: Running Get-GivenName function
2019-07-17 12:17:52 INFO: Current security context is not associated with an Active Directory domain or forest..
2019-07-17 12:17:52 INFO: No given name found. Using placeholder
2019-07-17 12:17:52 INFO: Creating the xml for displaying both action button and dismiss button
Issues:
1. User permissions need to change to program data folder so that the log can be written back to.
2. Same issues as above when running the ps1 from a network share. Have had to move the file locally and configure the SCCM package accordingly.
3. Is there a way to set the option to force a reboot and not just remove the notification?
Just a quick question.
How do you run this via SCCM when you have a pending reboot frem e.g. at Software Update deployment?
If you have a pending reboot in SoftwareCenter from a SoftwareUpdate deployment, further deployments are blocked until you execute the restart.
Same here, scripts unzipped out of the box no modifications, all in c:\temp\
I run from PS console – no matter elevated or not, local user:
PS C:\temp\ToastNotificationScript> .\New-ToastNotification.ps1 -Config .\config-toast.xml
I get this:
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: PendingRebootUptime set to True. Checking for device uptime
VERBOSE: Greeting with given name selected. Replacing HeaderText
VERBOSE: Running Get-GivenName function
VERBOSE: No given name found. Using placeholder
VERBOSE: Creating the xml for displaying both action button and dismiss button
VERBOSE: Toast notification is used in regards to pending reboot. Uptime count is greater than -3
VERBOSE: All good. Displaying the toast notification
Nothing displays
Fresh Windows 10 1903
Notifications enabled
Is focus assist enabled? Does the toast go directly into the action center? 🙂
> Is focus assist enabled?
It is not enabled all default settings BUT after reboot I see all my previously missing notifications in the notification center and the script seems to be working now (config-toast-osupgrade.xml does not show but I guess this may be related to other settings etc.)
Nice thing is that the notification stays and wont disappear until clicked, although perhaps that is controlled in xml as well.
Glad it’s working 🙂
> “Nice thing is that the notification stays and wont disappear until clicked, although perhaps that is controlled in xml as well.”
This is managed in the xml. Take a look at Option Name=”Scenario” Type=”reminder”
Hi,
I’m trying to implement your script to remind our users to reboot their pc on a regular basis. But when enabling the Snooze button, no buttons at all are shown. The snooze dropdown box are shown.
Have tried on both Windows 10 1809 and 1903.
Plz help
Best regards
Kim
I’ll try once more:
I don’t get any buttons when enabling the Snooze Button. I get the Snooze dropdown box, but none of the buttons are visible. What could that be?
I have tried on both Win10 1809 and 1903.
Best regards
Kim Knudsen
Kim, can you please sent me an email with some more details? I’m not sure what you are seeing, but I think this is better suited on an email: mab@imab.dk. Thanks 🙂
To show all 3 Restart/Snooze/Dismiss, you have to set this in the xml
Hello,
I am looking through the provided PDF that comes with the zipped folder and I am not seeing anything that talks about the provided MSI. I was wondering if the preferred method of having the script run on a regular basis is to create a recurring deployment in SCCM or does the MSI setup some sort of scheduling?
Thanks,
Brandon Bates
Hello Martin,
this looks like a great tool, thanks for sharing it!
I just wanted to inform you, that the “hidden.vbs” Script is considered as Grayware from Trendmicro (Grayware HackTool.VBS.InviBat.A ). I guess we will have to work around that for us, I just thought i should share this information.
kind regards,
Philipp Figel
Thanks – I have heard that before I think, but never with Windows Defender. The file is harmless though, though it’s intend is to run something hidden 🙂
i have followed the instruction-and configured as both a package and an application and still no success. I even switched to using default and not share location
powershell.exe -ExecutionPolicy Bypass -NoLogo -NonInteractive -NoProfile -WindowStyle Hidden -File .\New-ToastNotification.ps1
using sccm 1910
Can you share any logs with me? 🙂
Hello Martin,
First of all thanks, i love this script. I added some functions. I believe you’ll be interested.
Windows 10 Toast Notification Script Custom Action Protocols.msi file is no longer required and it works quietly.
I added a confirmation module.
Which user did the script work on? I created the CheckedUserRuning module for this. Sends the information it is running to the log file.
I created the AppVersionTest module for older version application detection.
Optional audio file can be added.
I emailed the Script file. I’d be happy if I could make a contribution. I hope I have helped.
Again, thank you.
Thank you Onur. I sent you an reply on your e-mail. Thanks again 🙂
Hello!
First of all, thank you a lot for your incredible work! 🙂
I am working on your Toast Notification, trying to implement it into my park and I was wondering if they were a way to modify your “Windows-10-Toast-Notification-Script-Custom-Action-Protocols.msi” program? (If not, I will extract the content of the application and create mine)
I just wanted to add some functionalities and modify one of the available scripts (the reboot one).
Hello! If you’re interested, I can send you the advanced installer project for you to modify yourself? If interested, drop me an email on mab@imab.dk and I will reply with the project 🙂
Hello! I have send you an email this morning. Thank you for your answer 🙂
Great coding. Thank you very much for that. I have used this a few times, deployed via intune to devices, mainly as a notification of outage. Using the IntuneWinAppUtil.exe, I converted the files to a Win32 app and deployed. My detection method is looking at the log file modified value timestamp.
So it doesn’t flash a powershell script in the background, I am using the silent command line “wscript.exe .\hidden.vbs .\*.cmd ”
Running a manual test, the greeting works great, but when running it through the system, it does not. Not quite sure about that one.
Looking forward to new features – once again , thanks for the great work.
Hi!
Thank you for great script. I can’t find Windows 10 Toast Notification Script Reboot Protocol.msi… where it can be downloaded?
Hi, that’s not needed anymore. Take a look at my recept version, where the custom protocols can be created by the script itself.
Hi you need to change lines 150 & 153 if you’re using a different xml file to run the trigger with. When the system account places a scheduled task the command line is wrong. Notice it now includes the -XMLSource. Awesome script.
To call the trigger pass the command line from SCCM or intune.
powershell.exe -executionpolicy bypass -command { C:\pathtotoastyscript.ps1 -XMLSource ‘customname.xml’ }
From
$Task_Action = New-ScheduledTaskAction -Execute “C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe” -Argument “-NoProfile -WindowStyle Hidden -File “”$New_ToastPath”” -ToastGUID “”$ToastGUID”” -Snooze”
To
$Task_Action = New-ScheduledTaskAction -Execute “C:\WINDOWS\system32\WindowsPowerShell\v1.0\PowerShell.exe” -Argument “-NoProfile -WindowStyle Hidden -File “”$New_ToastPath”” -XMLSource “”$XMLSource”” -ToastGUID “”$ToastGUID”” -Snooze”
Thanks for the script it is great!
I am receiving an error when I use the script ti run a task sequence(Package) from system center.
The error I receive is – Write-Log – PackageID : XXXX was not found in WMI as deployed to the client. I verified the package ID in System Center and the package is deployed to the machine – it is available in windows updates.
I verified the program is running as user and deployed when only a user is logged onto machine.
What am I missing?
Hi Martin,
Nice script, thanks a lot for your work! I am trying to use it for Office migration (with a TS).
I am deploying the script as a Required deployment running under Current User rights, is that correct?
The second question is about snoozing – should I re-run the script periodically or it can nuge a user itself until deadline set for a migration TS? Can it survive a reboot between snoozes (I do not see any custom scripts in scheduler)?
Thank you!
Hi, right. Current user context is preferred. I recommend to rerun the script periodically suiting your schedule, instead of allowing snooze. Snooze doesn’t really go well in this scenario in my opinion. The snooze action is handled by the OS itself. ConfigMgr doesn’t know if a user has chosen to snooze the toast. I believe a snooze survives a reboot.
I used this solution a couple of years ago to help drive Windows OS upgrades, it proved invaluable. Great to see how it’s evolved.
The only question I have is how are people deploying this and then presenting the notification? We have ConfigMgr and nearly all our users/devices are remote.
It would be nice to centralise the XML config but connectivity/latency would be a concern. What approach have people taken? Packaging this and deploying as a complete app to “Program Files”? Updating and adding XML through package updates rather than an on premises repo/share? Anything related to an OS upgrade or something in Software Center linked to a ConfigMgr deployment? Business related notifications to a scheduled task?
I would love to see some examples, thank you in advance.
Has anyone been able to add a notification sound? or can anyone tell me how to do it?
Does anyone know how to change some of the text in a notification?
Example:
Your device was last restarted 5 days ago. You will receive a one-hour warning on day 6 before your device restarts. Taking action to restart prior will avoid disruption in your workday.
I want to be able to change this part of the notification text to red.
Taking action to restart prior will avoid disruption in your workday.
Thanks for any help.
The toast notification framework in Windoes does not have the ability to format text like that I’m afraid. 🙂
Is there a way to change the toast text color?
Example:
Your device was last restarted 5 days ago. You will receive a one-hour warning on day 6 before device restarts. Take action to restart prior will avoid disruption to your workday.
What to change this part of the message to red.
Take action to restart prior will avoid disruption to your workday.
Thanks