Skip to content

Instantly share code, notes, and snippets.

@paveltimofeev
Created September 10, 2015 10:37
Show Gist options
  • Save paveltimofeev/909f86edae9350c72051 to your computer and use it in GitHub Desktop.
Save paveltimofeev/909f86edae9350c72051 to your computer and use it in GitHub Desktop.
Show-BalloonTip
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