Tool-highlight: Show Windows Toast Messages with PowerShell

Happy New Years, everyone!

This will be a quick post here, but I just wanted to shine a spotlight on an AWESOME tool that I absolutely love: Joshua King’s ‘BurntToast’ PowerShell module, which makes the arduous task of rendering a Windows Toast notification VERY Easy.

Check out his GitHub repo here, and view the module’s page on the PowerShell gallery here.

Here’s an example of what I’m talking about

en

Why might I want to use this?

Any time you want to provide data to the end-user, but not require them to drop everything to interact. I don’t know about you, but I really dislike alert dialog boxes.  Especially if they lock my whole desktop until I quickly ignore it and click the ‘X’ button…err, read it.

I also believe that toasts are what users expect, especially to receive updates from long-running scripts.  They really do provide a polished, refined look to your scripts.

Finally, you can also provide your own image and play your own sound effects too!

Real-time encryption notices

At a current customer, we’re deploying a device management profile using MDM to use BitLocker encryption on these devices.  We decided that it would be very useful to be able to see updates as a device was encrypting, so I wrote up this script around the BurntToast tool.

install-module BurntToast -Force
Import-module BurntToast

$EncryptionStatus = Get-BitLockerVolume -MountPoint c:

    While ($EncryptionStatus.VolumeStatus -eq 'EncryptionInProgress'){

        if (($EncryptionStatus.EncryptionPercentage % 5)-eq 0){
            New-BurntToastNotification -Text 'Encryption Progress', "Now $($EncryptionStatus.EncryptionPercentage)% completed."
        }

        Start-Sleep -Seconds 30

        $EncryptionStatus = Get-BitLockerVolume -MountPoint c:
        Write-host $EncryptionStatus.EncryptionPercentage
        }

New-BurntToastNotification -Text 'Encryption Completed' 'Now completed.' -Image "C:\Users\sred1\Dropbox\Docs\blog\foxderp - Copy.png"

And a screen shot of it in action!

encryption-percentage

3 thoughts on “Tool-highlight: Show Windows Toast Messages with PowerShell

  1. Gurumurthy Gunasekaran January 9, 2017 / 5:53 am

    Hi Stephen,
    Is is possible to have this for a chat application we’re using the XMPP protocol and the spark as a client software. I’d likes to try because while working in a remote system i don’t receive the notification in that software so that this might be a helpful one…

    • FoxDeploy January 12, 2017 / 9:10 am

      Anything is possible. How do you plan on your desktop knowing there’s a new message on the remote machine?

      • Gurumurthy Gunasekaran January 13, 2017 / 12:37 am

        I’m planing to show the message that should be shown anywhere else i’m working in that system. Have you seen that notifications from that Gtalk it will shown you on the right below corner… That notifications will not shown while your’re in the remote system with full screen… But the windows default toast notifications will shown anywhere you’re using even that is full screen in remote… So i have to setup that software to receive the notification and show it as windows notifiication… And BTW I’m not a developer, i have seen your article in the right time when i got this idea… I’ll try and tell you on this post if i succeeded…

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s