During my presentation at the Dogfood Conference in Columbus Ohio this morning, there was a lot of interest about the balloon tips that popped up during my script execution. I thought I would do a quick post to share this, as I recently saw it on my daily PowerShell.com PowerTip email and loved it enough to incorporate it into my “Build Your SharePoint Internet Presence with PowerShell” demonstration.
It’s pretty much as simple as creating a new System.Windows.Forms.NotifyIcon object and then setting some properties and calling the ShowBalloonTip() method.
Here’s my version of it, which I created as a function so I could call it like a Cmdlet:
function New-BalloonTip { [CmdletBinding()] Param( $TipText='This is the body text.', $TipTitle='This is the title.', $TipDuration='10000' ) [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 = $TipText $balloon.BalloonTipTitle = $TipTitle $balloon.Visible = $true $balloon.ShowBalloonTip($TipDuration) }
Here’s how you run it:
New-BalloonTip -TipTitle "This is the title" -TipText "This is my custom message"
And here’s what it looks like:
Reblogged this on Share… What? and commented:
Notify when your powershell script needs to be paid attention.