SHARE
TWEET

Add-WindowsNotification

Flimbot Feb 19th, 2020 78 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function Add-WindowsNotification{
  2.     Param(
  3.         [parameter(Mandatory=$true)][ValidatePattern('^[\w\-]+$')][String]$AppId,
  4.         [parameter(Mandatory=$true)][ValidateLength(1,108)][String]$Message
  5.     )
  6.  
  7.    
  8.     $notificationTemplate = [Windows.UI.Notifications.ToastTemplateType]::ToastText01
  9.  
  10.     $notification = [Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($notificationTemplate)
  11.     $textElement = $notification.SelectSingleNode('/toast/visual/binding/text')
  12.     $textElement.innerText = $message
  13.     $notificationInstance = New-Object Windows.UI.Notifications.ToastNotification $notification
  14.     $notificationManager = [Windows.UI.Notifications.ToastNotificationManager]::GetDefault()
  15.     $notifier = $notificationManager.CreateToastNotifier($AppId)
  16.     $notifier.show($notificationInstance)
  17.  
  18. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top