Embedding a base64 image string inside a Powershell Application


Base64 is a binary-to-text encoding scheme – in other words, we can represent binary data (for example, a JPG or a PNG) as an ASCII string.

For me it was useful when I was compiling a PS1 script into an executable.  The tool I was using to compile it with didn’t have support for associated files, so I needed to include everything in the PS1 script.  When used as part of a webpage, it can reduce load time due to limiting the amount of HTTP request/responses.

In this script, I demonstrate embedding a base64 image string inside a Powershell application how we can use base64 encoding to add an icon, a picture and a memory stream email attachment in our Powershell application.

To convert an image to a base64 string, I use this website: http://www.base64-image.de