Back in the day when I was just a wee little lad and more of a punk, we used to practice our l33t h@ck3rZ in school. One of the cool, rebellious ways we would do this was by sending messages to other computers via the NET SEND command. They would usually say something innocent like, “SYSTEM MALFUNCTION. OVERHEAT IMMINENT. FIRE LIKELY. SHUTDOWN IMMEDIATELY.” Much like everything on the internet being true, if it popped up on your computer screen in a black terminal it was 100% legit, 100% of the time. Man…those were some good times. You know, the ones where your one singular mission was to circumvent the school firewall? No? Just me? Sure, okay… Well, as fun as those times were, Microsoft has now introduced something cooler for mature adults called Windows Toast Notifications.

\\\It’s so toasty in here

The concept isn’t new as we’ve been getting popped up on since the first caveman offered 10% coupon for rocks, but with Windows 10 came the new and improved pop up. Slightly less annoying and a heck of a lot fancier, Toast Notifications can be used for all sorts of annoying informational purposes. It looks like this:

Darth Vader - Toast Notification

Well, the only thing better than toast for breakfast, lunch, and dinner is the fact that we can send toast notifications via PowerShell. Now if only we could harness that behavior-reinforced sound of bread jumping out of the toaster slot we’d be set. Until that day, we’ll settle for plain, dry toast with no jam.

\\\Burn Baby Burn

Aptly named from your childhood memories, we can display toast notifications with the…BurntToast module. Why couldn’t it be SlightlyBurntToast or MediumRareToast? We’ll never know. But if you’re used to burning your toast you’ll feel right at home. Let’s install it from the gallery using this command (run PS with elevated permissions):

Install-Module BurntToast
If prompted, press Y because we blindly accept anything to install the software we desire.

Before we get started putting it all together, let’s take a step back and look at the some of the key parts of our bread before we toast it. The simplest toast notification includes a title and a message. These can be combined into one parameter called -Text.

Let’s see what this looks like:

New-BurntToastNotification -Text "Alerty Alert Alert","Meet me at the you-know-where and drop off the you-know-what"
Toast Notification 1
We’re passing two argument strings to the -Text parameter, the first being the title and second being the message.

But wait, there’s more! For all of the visual learners out there we can also add an image to our notification using the -AppLogo parameter:

New-BurntToastNotification -Text "Alerty Alert Alert","Meet me at the you-know-where and drop off the you-know-what" -AppLogo "C:\\TopSecret.jpg"
And that’s not all. We can also give this message a unique identifier with the aptly named -UniqueIdentifier so we can easily send another message to overwrite our previous message. This is convenient if you don’t the messages to stack but to replace each other:
New-BurntToastNotification -Text "Alerty Alert Alert","Meet me at the you-know-where and drop off the you-know-what" -AppLogo "C:\\TopSecret.jpg" -UniqueIdentifier '001'
Toast Notification 2

\\\Just Add Butter

Most things in life are better with butter, and our toast could use a button to top it off. We can add a button by building a button with a separate cmdlet, storing as a variable, and then referencing it in our New-BurntToastNotification cmdlet. Let’s take a look at the New-BTButton cmdlet and how to use it. We have a few parameters to choose from depending on what we want the button to do. We can make the button action dismiss the notification with -Dismiss, snooze with -Snooze, or launch something else with the -Arguments parameter. For our example, we want the button to dismiss the notification and we’ll store in a top secret variable called $Button.

$Button = New-BTButton -Content 'I Do Not Care' -Dismiss

\\\That’s My Jam

We also have the ability to send multiple notifications under one header. This comes in handy if you want one single app/process to give multiple status updates along the way. Think of it like a plate for your toast. We don’t have too many options with this one, but we can give the Header a Title and optionally define Arguments to make it “clickable” like a button. For our purposes, let’s just define the header without defining -Arguments.

$Header = New-BTHeader -Title 'Central Command'

Okay, so after adding in the butter and the jam to our toast, let’s see the finished block of code:

$Header = New-BTHeader -Title 'Central Command'
$Button = New-BTButton -Content 'I Do Not Care' -Dismiss
New-BurntToastNotification -Text "Alerty Alert Alert","Meet me at the you-know-where and drop off the you-know-what" -AppLogo "C:\\SuperLogo.png" -UniqueIdentifier '001' -Header $Header -Button $Button
Toast Notification 3

And now you can burn your toast in style. Add this to your scripts to alert yourself of your progress. In a future post we’ll get all fancy and experiment in our PowerShell kitchen. Lookout Panera Bread!

And the million dollar question: is it named after the bread or the act of clinking glasses together in honor of something?

OTHER POSTS YOU WANT TO READ

Index Scripts for Windows Search

So you just finished writing some code and you go to save your file. You summarize all of the important aspects this section of code contains into a nice, easy-to-read file name that your future self will immediately recognize. Fast forward to the future where you...

Array vs ArrayList (PowerShell)

For some tasks in life, being precise is a necessity. But most of us get away with rounding, paraphrasing, and hitting in the general vicinity most of the time. Depending on your personality, you may be one who strives for perfection and strains on every miniscule...

Spice Up HTML Emails with PowerShell – Part III

So far in this series we've fumbled our way around the kitchen and tried to wing it when sending HTML emails with PowerShell. It was clunky to say the least. We then went through our spice rack and built an HTML template, highlighting the nuances of each spicy element...

Spice up HTML Emails with PowerShell – Part II

In Part I of our scrumptious concoction we put our script into the oven to let it bake. But we forgot to add our secret sauce that's sure to leave our recipients drooling, which is clearly our goal. In this post we'll continue to spice up HTML emails with PowerShell...

Spice Up HTML Emails with PowerShell – Part I

I live in the South, specifically in God's country AKA TEXAS BABAY! There's plenty of amazing things about Texas and definitely some reasons to loathe being from Houston, but it's hard to knock our food. I mean, is there really even a debate between Whataburger vs...
%d bloggers like this: