Fun with PowerShell – Balloon Tips

This is a tip from PowerShell.com.  I’ve slightly changed the text and title to make the boss man smile every time he reads this post.  Smile

Displaying Balloon Tip

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

[sourcecode language=”powershell”]
[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.BalloonTipTitle = ‘itgroove Kicks Ass!’
$balloon.BalloonTipText = ‘itgroove. To have fun with technology. Doing IT with style.’
$balloon.Visible = $true
$balloon.ShowBalloonTip(10000)
[/sourcecode]

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.

clip_image002