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:
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):
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
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"
-Textparameter, 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
New-BurntToastNotification -Text "Alerty Alert Alert","Meet me at the you-know-where and drop off the you-know-what" -AppLogo "C:\\TopSecret.jpg"
-UniqueIdentifierso 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'
\\\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 = 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
$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
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?