Dismiss a Snoozed Toast Notification Before It Shows Again

Use PowerShell to programmatically delete/dismiss a snoozed toast notification that's no longer applicable before it is displayed to the user again.

In my org, I have a custom Reboot Reminder toast notification that is triggered by a PowerShell script.  It's pretty basic - just a simple reminder message and the normal Snooze and Dismiss button set.  

Occasionally, a user will see the notification and snooze it for a large duration, like 4 hours.  Then, maybe 2 hours later, they reboot the PC.  Another 2 hours later, the 4 hour snooze duration expires and the original reboot reminder pops up reminding them again to reboot the PC.  They obviously just rebooted, so the reminder is no longer accurate.  Ideally, the snoozed reminder should be programmatically deleted upon the reboot so that the user doesn't get a stale reminder that no longer applies.

When a user snoozes a toast notification, a new ScheduledToastNotification instance is created to trigger the same toast again later.  Using the ToastNotifier class, we can search for all scheduled notifications for a given AppID, parse the text content of those instances to find the ones we're interested in, and then selectively delete them.

Here's the basic PowerShell code.  Just make sure to populate the $appId and $searchText variables to match your use case.

$appId = 'adminsccm.com' # This should match whichever AppId you're using to create the toasts
$searchText = '*Days Since Last Reboot*' # A text string that exists only in the toasts that you're trying to match. Or set to '*' if you want to match anything.

$Load = [Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$toastNotifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($appId)
$scheduled = $toastNotifier.getScheduledToastNotifications()

    if ($_.Content.InnerText -like $searchText)

If you trigger this script to run at user logon after a reboot, then any previously snoozed reboot reminders will get wiped out and the user will no longer get the erroneous reminder toast.

I hope this was helpful. If you have any comments or questions, or if you have an idea about how to further improve this approach, you can connect with me via Twitter.