Skip to content

Instantly share code, notes, and snippets.

@khazeamo
Last active August 13, 2018 10:54
Show Gist options
  • Save khazeamo/ffe5c0730973e110782cb3bd9c94a882 to your computer and use it in GitHub Desktop.
Save khazeamo/ffe5c0730973e110782cb3bd9c94a882 to your computer and use it in GitHub Desktop.
PowerShell Toast Notification
$app = '{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe'
[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]
$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01
#Gets the Template XML so we can manipulate the values
[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())
[xml]$ToastTemplate = @"
<toast duration="long" launch="app-defined-string">
<visual>
<binding template="ToastImageAndText02">
<text id="1">Ticketing Service</text>
<text id="2">Please check tickets in BMC Service Desk</text>
<image id="1" src="file:///c:/util/TicketingNotifications/aargau.png" />
</binding>
</visual>
</toast>
"@
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)
$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)
$notify.Show($ToastXml)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment