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 Cloud and Datacenter Management & Data Platform MVP who has worked in IT for over 20 years. She is the creator of the popular SQL PowerShell module dbatools, and holds a number of certifications, including those relating to SQL Server, Linux, SharePoint and network security. 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 *

*