Use base64 for NotifyIcon in PowerShell

In addition to be able to use base64 for Images in WPF-based PowerShell Forms, you can also use base64 for icons as well. Essentially, you take the base64, convert it to a memory stream, draw an image from that stream, then convert the image to an icon. Finally, you assign the $notify.Icon this new variable.

Just the NotifyIcon Part

Easy enough, right? So what if you want to use base64 as both an icon and as an image within the form? Check out the code below.

NotifyIcon + base64 WPF Image

To get this:
small-form

Use this (taking note of the comments):

PowerShell + WPF = <3

Chrissy is a PowerShell MVP who has worked in IT for nearly 20 years, and currently serves as a Sr. Database Engineer in Belgium. Always an avid scripter, she attended the Monad session at Microsoft’s Professional Developers Conference in Los Angeles back in 2005 and has worked and played with PowerShell ever since. Chrissy is currently pursuing an MS in Systems Engineering at Regis University and helps maintain RealCajunRecipes.com in her spare time. She holds a number of certifications, including those relating to SQL Server, SuSE Linux, SharePoint and network security. She recently became co-lead of the SQL PASS PowerShell Virtual Chapter. You can follow her on Twitter at @cl.

Posted in PowerShell, WPF
One comment on “Use base64 for NotifyIcon in PowerShell
  1. Rich says:

    I just plugged your “icon from base64 code” into a function and went from a script with a single external icon file to a script with an array of status-changing icons in a few minutes. Very nice, thanks for sharing.

Leave a Reply

Your email address will not be published. Required fields are marked *

*