Created
January 31, 2020 11:23
-
-
Save Thecarisma/0eb8a1e7eb64ac6762eb83eb116a4da4 to your computer and use it in GitHub Desktop.
A Powershell script to send Windows Toast notification. Usage: sendwintoast.ps1 "Your Title" "Your Message" Info
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Param([string]$Title,[string]$Message,[string]$MessageType) | |
Add-Type -AssemblyName System.Windows.Forms | |
$global:balloon = New-Object System.Windows.Forms.NotifyIcon | |
Get-Member -InputObject $Global:balloon 2>&1 | Out-Null | |
[void](Register-ObjectEvent -InputObject $balloon -EventName MouseDoubleClick -SourceIdentifier IconClicked -Action { | |
$global:balloon.dispose() | |
}) | |
$path = (Get-Process -id $pid).Path | |
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) | |
[System.Windows.Forms.ToolTipIcon] | Get-Member -Static -Type Property 2>&1 | Out-Null | |
$balloon.BalloonTipIcon = [System.Windows.Forms.ToolTipIcon]::Warning | |
$balloon.BalloonTipText = $Message | |
$balloon.BalloonTipTitle = $Title | |
$balloon.Visible = $true | |
$balloon.ShowBalloonTip(5000) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment