Last active
February 15, 2025 23:13
-
-
Save balazsbotond/87ce12b77fbeb742b0663628efb32984 to your computer and use it in GitHub Desktop.
PowerShell script for sending Windows 10 notifications
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$ErrorActionPreference = "Stop" | |
$notificationTitle = "Build Succeeded" | |
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null | |
$template = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent([Windows.UI.Notifications.ToastTemplateType]::ToastText01) | |
$toastXml = [xml] $template.GetXml() | |
$toastXml.GetElementsByTagName("text").AppendChild($toastXml.CreateTextNode($notificationTitle)) > $null | |
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument | |
$xml.LoadXml($toastXml.OuterXml) | |
$toast = [Windows.UI.Notifications.ToastNotification]::new($xml) | |
$toast.Tag = "Test1" | |
$toast.Group = "Test2" | |
$toast.ExpirationTime = [DateTimeOffset]::Now.AddSeconds(5) | |
$notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Script Completed!") | |
$notifier.Show($toast); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
How would you add a picture/icon to the notification?