Creating a Balloon Tip Notification in PowerShell

Ever want to display a balloon tip notification for something in PowerShell? No? Well, it’s cool. Maybe you should try it out!

[reflection.assembly]::loadwithpartialname("System.Windows.Forms")
[reflection.assembly]::loadwithpartialname("System.Drawing")
$icon = new-object system.drawing.icon("c:\myscriptsicon.ico")
$notify = new-object system.windows.forms.notifyicon
$notify.icon = $icon
$notify.visible = $true
$notify.showballoontip(10,"Title","Message", `
[system.windows.forms.tooltipicon]::warning)

On that last line, the 10 is the number of seconds to display the tip. The Warning icon could also be Error or None, depending on your need. Finally, note that you do need to load a valid .ICO icon file – I used a sample icon file I had, but you’ll need to obtain a legit .ICO file to make the third line work.

Set $notify.visible = $false to get rid of the icon; if you just close the shell, the icon will stay visible until you try to move your mouse over it – then Windows will “realize” it’s gone and remove it.