You’ve been there. Running a long PowerShell script that you know will take more than a few seconds (maybe minutes or even hours). Either you are running the script and leaving it up on a second monitor, or you are periodically alt-tab’ing back to it to see it’s progress. Either way, I’ve started using the Windows notifications to inform me of progress with my scripts and I have to say, I really like it. I decided as I was using it this weekend that I would finally throw it into a function and post it on Github. I do not recall where I originally found this ability, but I have since taken it and modified it for my needs.

 

What does it do?

Set-TaskbarNotification allows users to create popup notifications in the bottom-right of their screen from PowerShell. In the images below, I have the command I ran and the notification popup that corresponded to each command. As you can see, this is very simple and straightforward and can allow users to continue on with their day-to-day tasks, while still receiving updates from scripts they are running.

How does it work?

This script taps into the ‘System.Windows.Forms.NotifyIcon’ object. In this function, I’ve created a number of checks that makes using it so easy that the only required field is the actual message itself.

  • If you do not add a title, it will automatically take the title of the PowerShell session window that it is running from (default will be ‘Windows PowerShell’ unless you run scripts to change the titles of your PS sessions)
  • It sets a default notification timeout of 5 seconds. This can be changed with the -TimeoutMS parameter
  • It sets the default balloon icon to ‘info’ although you can specify “None”,“Info”,“Warning”,“Error” with the -BalloonIcon parameter
  • It sets the default taskbar icon to the PowerShell icon, but you can change that as well.

Where can I get it?

You can find it on my github page, here https://github.com/vtagion/Scripts/blob/master/Set-TaskbarNotification.ps1

 

Try it out and drop me a comment on here or twitter if you found it useful!

 

Written by

Brian

Brian Graf is a Sr. Technical Marketing Manager for VMware Cloud on AWS at VMware. He has also worked on ESXi Lifecycle, PowerCLI Automation and been the Product Manager for vSphere DRS and HA. Brian is co-author of the PowerCLI Deep Dive 2nd edition book and a Microsoft MVP.

Leave a Reply

Your email address will not be published.Required

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">

You May Also Like to Read

Bitnami