-
Notifications
You must be signed in to change notification settings - Fork 0
/
toast.ps1
12 lines (11 loc) · 875 Bytes
/
toast.ps1
1
2
3
4
5
6
7
8
9
10
11
12
param ([string] $Subject, [string] $Body = $null)
$subject = [Security.SecurityElement]::Escape($subject)
$body = [Security.SecurityElement]::Escape($body)
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
[Windows.Data.Xml.Dom.XmlDocument, Windows.Data.Xml.Dom.XmlDocument, ContentType = WindowsRuntime] > $null
[Windows.UI.Notifications.ToastNotification, Windows.UI.Notifications, ContentType = WindowsRuntime] > $null
$xml = New-Object Windows.Data.Xml.Dom.XmlDocument
$template = "<toast><visual><binding template=`"ToastText02`"><text id=`"1`">$Subject</text><text id=`"2`">$Body</text></binding></visual></toast>"
$xml.LoadXml($template)
$toast = New-Object Windows.UI.Notifications.ToastNotification $xml
[Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("Toast").Show($toast)