$ErrorActionPreference = "Stop" | |
$notificationTitle = "Notification: " + [DateTime]::Now.ToShortTimeString() | |
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null | |
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01) | |
#Convert to .NET type for XML manipuration | |
$toastXml = [xml] $template.GetXml() | |
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null | |
#Convert back to WinRT type | |
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument | |
$xml.LoadXml($toastXml.OuterXml) | |
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml) | |
$toast.Tag = "PowerShell" | |
$toast.Group = "PowerShell" | |
$toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(5) | |
#$toast.SuppressPopup = $true | |
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell") | |
$notifier.Show($toast); |
This comment has been minimized.
This comment has been minimized.
very useful, thanks! |
This comment has been minimized.
This comment has been minimized.
An idea to workaround the "Windows PowerShell cannot subscribe to Windows RT events" error when trying to subscribe to the Activated event of the toast? |
This comment has been minimized.
This comment has been minimized.
awesome! thanks |
This comment has been minimized.
This comment has been minimized.
How can I avoid the toast will be deleted after 6 seconds no matter what expiration time is setted? :( |
This comment has been minimized.
This comment has been minimized.
nice work, thank you! |
This comment has been minimized.
This comment has been minimized.
This doesn't work for me for some reason. No error either. I have latest version of Windows 1709 16299.125 completely up-to-date. |
This comment has been minimized.
This comment has been minimized.
@mikeyhalla |
This comment has been minimized.
This comment has been minimized.
Yes it's broken now, if anyone found an alternative I'm interested :) Edit: found the solution, use a real AppId, example here: https://gist.github.com/Windos/9aa6a684ac583e0d38a8fa68196bc2dc explanation here: https://stackoverflow.com/a/46817674/172074 |
This comment has been minimized.
This comment has been minimized.
See also https://github.com/Windos/BurntToast |
This comment has been minimized.
Thanks!