Created
September 10, 2015 10:37
-
-
Save paveltimofeev/909f86edae9350c72051 to your computer and use it in GitHub Desktop.
Show-BalloonTip
This file contains hidden or 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
function Show-BalloonTip | |
{ | |
[CmdletBinding(SupportsShouldProcess = $true)] | |
param | |
( | |
[Parameter(Mandatory=$true)] $Text, | |
[Parameter(Mandatory=$true)] $Title, | |
[ValidateSet('None', 'Info', 'Warning', 'Error')] $Icon = 'Info', | |
$Timeout = 10000 | |
) | |
Add-Type -AssemblyName System.Windows.Forms | |
if ($script:balloon -eq $null) | |
{ | |
$script:balloon = New-Object System.Windows.Forms.NotifyIcon | |
} | |
$path = Get-Process -id $pid | Select-Object -ExpandProperty Path | |
$balloon.Icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path) | |
$balloon.BalloonTipIcon = $Icon | |
$balloon.BalloonTipText = $Text | |
$balloon.BalloonTipTitle = $Title | |
$balloon.Visible = $true | |
$balloon.ShowBalloonTip($Timeout) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment