Displaying Balloon Tip

by Sep 27, 2011

Let's assume your script wants to share status information via a balloon message in the system tray area. Here is a sample:

[system.Reflection.Assembly]::LoadWithPartialName('System.Windows.Forms') | Out-Null
$balloon = New-Object System.Windows.Forms.NotifyIcon
$path = Get-Process -id $pid | Select-Object -ExpandProperty Path
$icon = [System.Drawing.Icon]::ExtractAssociatedIcon($path)
$balloon.Icon = $icon
$balloon.BalloonTipIcon = 'Info'
$balloon.BalloonTipText = 'Completed Operation'
$balloon.BalloonTipTitle = 'Done'
$balloon.Visible = $true
$balloon.ShowBalloonTip(10000)

Note that the code uses the icon of your PowerShell application inside the tray area so the user can associate the message with the application that produced it.

Twitter This Tip!
ReTweet this Tip!