Skip to content

Instantly share code, notes, and snippets.

@warfighter8
Created June 29, 2018 14:29
Show Gist options
  • Save warfighter8/2b39d65bfb2140a42e8225b6cc23a380 to your computer and use it in GitHub Desktop.
Save warfighter8/2b39d65bfb2140a42e8225b6cc23a380 to your computer and use it in GitHub Desktop.
sample powershell for windows 10 toast notifications
$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 launch="app-defined-string">
<visual>
<binding template="ToastGeneric">
<text>You've been at your desk for a while</text>
<text>It's time to get 🆙 &amp; 🚶❕</text>
</binding>
</visual>
<actions>
<action activationType="background" content="Drink verification can" arguments="later"/>
</actions>
</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