Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save gpuido/2f710bafca0a06c1062d35fc5654e69a to your computer and use it in GitHub Desktop.
Save gpuido/2f710bafca0a06c1062d35fc5654e69a to your computer and use it in GitHub Desktop.

Revisions

  1. @altrive altrive revised this gist May 2, 2015. 1 changed file with 1 addition and 15 deletions.
    16 changes: 1 addition & 15 deletions ToastNotification_Windows10.ps1
    Original file line number Diff line number Diff line change
    @@ -20,18 +20,4 @@ $toast.ExpirationTime = [DateTimeOffset]::Now.AddMinutes(5)
    #$toast.SuppressPopup = $true

    $notifier = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier("PowerShell")
    $notifier.Show($toast);

    <#
    $toasts = [Windows.UI.Notifications.ToastNotificationManager]::History.GetHistory()
    if ($toast -ne $null)
    {
    $count = $toasts.Count()
    [TileServices]::SetBadgeCountOnTile($count)
    $badgeXml = [Windows.UI.Notifications.BadgeUpdateManager]::GetTemplateContent([Windows.UI.Notifications.BadgeTemplateType]::BadgeNumber)
    $badgeXml.badge.value = $count.ToString()
    $badge = [Windows.UI.Notifications.BadgeNotification]::new($badgeXml)
    [Windows.UI.Notifications.BadgeUpdateManager]::CreateBadgeUpdaterForApplication().Update($badge)
    }
    #>
    $notifier.Show($toast);
  2. @altrive altrive created this gist May 2, 2015.
    37 changes: 37 additions & 0 deletions ToastNotification_Windows10.ps1
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@
    $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);

    <#
    $toasts = [Windows.UI.Notifications.ToastNotificationManager]::History.GetHistory()
    if ($toast -ne $null)
    {
    $count = $toasts.Count()
    [TileServices]::SetBadgeCountOnTile($count)
    $badgeXml = [Windows.UI.Notifications.BadgeUpdateManager]::GetTemplateContent([Windows.UI.Notifications.BadgeTemplateType]::BadgeNumber)
    $badgeXml.badge.value = $count.ToString()
    $badge = [Windows.UI.Notifications.BadgeNotification]::new($badgeXml)
    [Windows.UI.Notifications.BadgeUpdateManager]::CreateBadgeUpdaterForApplication().Update($badge)
    }
    #>