Keeping in touch with Windows Toast Notifications–CoronaToast

Given the current situation many people face worldwide with the outbreak of Covid-19 at the time of writing this, it has led to an increase in people working from home. For many organisations this is not unusual but for lots of others it is and not everyone is geared up for this. As someone who has been home-based for a long time now I understand the ups and downs of remote working, especially for extended periods. With the increased sensitivity around symptoms of this particular virus it is obviously very important to keep up with staff and make sure they are feeling well both from a physical and mental health perspective.

With this in mind I had some thoughts about pulsing employee on corporate devices about how they were feeling. My initial thought was to use custom notifications with Microsoft Endpoint Manager for employee phones but this isn’t so simple to do anything customised. So my next step was to look at toast notifications in Windows 10. Now, I’m very well aware there are other tools out there that can poll users – including Microsoft Teams – but in the absence of such tools I thought this may give an alternative.

Now, when I think of Windows 10 toast notifications the first thing I think of is fellow Microsoft MVP – Martin Bengtsson and his excellent work incorporating toast notifications with Configuration Manager for Windows PC upgrades. There’s a term used in IT – “Stealing with Pride” and that’s pretty much what I decided to try out as that’s why we share content right? So others can get benefit from it too. So I downloaded Martins existing toast script and had a poke around to see what I could do. My remit on this one was not quite the same as the excellent work he has done along with other contributors so I got familiar with the structure and decided to strip it back to what I needed by taking out the Operating System Deployment related parts. For full info on how the script works, please go visit Martins blog and give full credit his way as I know he’s put a lot of time and effort into it. I’m going to show what I did and give you the source, but please use Martins site for full understanding.

So, what am I talking about and what does it look like?

I have more ideas on this, but first pass is basically to prompt the managed device with a toast notification and the action on that toast notification simply links back to a Microsoft Form which I pre-created.

clip_image002

clip_image004

Because I’m using a Microsoft Form here, it automatically gathers the responses into a nice presentable format.

clip_image006

You do need Microsoft Office 365 for this and it’s really simple to make a form by visiting forms.office.com and logging in if you’re not already. There’s a really nice starters guide available from Microsoft here and you will find other content available if you search for it, but generally it’s pretty straight forward.

Once you’ve created your form you will need to make sure it’s shared appropriately so people can access it. You have options to share internally only or externally too, there are also different methods including URL, QR code, embedded link and email.

clip_image008

For my example I just took a copy of the URL using the copy button.

How does it work?

Again, for full tech info I want to push you to Martins blog as I’m stealing enough so he should at least get your traffic
But essentially, we have 3 main components.

  • PowerShell Script
  • XML Configuration File
  • Toast Images

The PowerShell script is run on the client device, it then references the configuration script for the relevant options and text to show, and also uses the images as part of the toast. It’s also worth noting there are different types of toast notifications available which are detailed by Microsoft here.

clip_image010 clip_image012 clip_image014

Because this script was developed with Microsoft Endpoint Manager in mind, we have 2 options for how it is run. We can run it as a notification off Software Center (from ConfigMgr) or we can run it as a PowerShell notification. I would suggest that if you’re using Configuration Manager then Software Center makes sense and if you’re using Intune (or another MDM) then the PowerShell option is better suited. You can change this preference in the XML with the “UseSoftwareCenterApp” or “UsePowerShellApp” set to true or false. Don’t set both, it won’t work.

Either way, you should be able use these with devices that are on-premises or not. If you’re using Configuration Manager, in the absence of a VPN you will need a cloud management gateway, but in my honest opinion you should really have one of those anyway. If you are using Intune, you’re already taking content from the internet.

You have options on how you might want to get this out to devices, so I’m not about to mandate which one but you could use:
Packages in Configuration Manager

  • Applications in Configuration Manager
  • Run Scripts in Configuration Manager (with a little tweaking perhaps)
  • PowerShell scripts in Microsoft Intune/Endpoint Manager Admin Center
  • Group Policy/Active Directory (maybe)

This would all depend on your use case, frequency and what tools you have available. You might have something completely non-Microsoft. Note though, that if you supply the XML file and images outside of the script they will need to be accessible to the user. You might keep these together, you might use a UNC for example.

You can download and take a look yourself, but there is a section in the script which pulls in data from the XML file. You can see some examples cross-referenced here.

clip_image016 clip_image018

It’s really extensible and that’s the beauty of the work that Martin put in. You can see in my example I have Enabled the various button types so that I show an Action button, a Snooze button and a Decline button. On the Action button I simply put the URL of my Microsoft form which I copied earlier, then this will fire up the default web browser and drop the user onto the form. I’m sure there’s more that can be done on this and I will play further but this for me is fine for now.

Now as per the instructions in Martins post, you can execute the PowerShell script and reference a specific configuration file. This means that you can maybe pre-stage a few different XML files and send them out at whatever schedule you want to with varying messages or styles.

Note also, that there is logging in this script and this will output to the users %APPDATA% location and generate a log file. Note you can also change the name of this in the script of you wish.

clip_image020

To run it, we can simply use this command with an optional reference to the configuration XML file. If you don’t it will look for a default config.xml file.

.\New-CoronaToast.ps1 -Config Config-Corona.xml

clip_image022

Then assuming all is well, up comes the toast message. You don’t have to use the snooze option but that also does as you would expect and comes back after X minutes.

clip_image024

I think that covers it. Again I wanted to make a point to say I didn’t develop all of this, I stole with pride and modified accordingly so go and see Martin Bengtsson over at imab.dk for the great stuff he has there.

DOWNLOAD

If you want to download a ZIP with the files, they are HERE from my site. I don’t actively use GitHub but I’ll put it up there soon too.

JUST TO BE CLEAR, I OFFER NO GUARANTEES, WARRANTIES OR SUPPORT. TEST THOROUGHLY AND USE AT YOUR OWN RISK.

I am however happy to take feedback and comments and time permitting I can modify it further.

Enjoy, look after and support people, especially when they need it the most.

/Peter

4 thoughts on “Keeping in touch with Windows Toast Notifications–CoronaToast

  1. That’s really nice.
    I was looking for something to do similar and pop up these messages on workstations reminding users to wipe down their surfaces, clean desks, close programs on Friday, etc. Some of the code is a little beyond me but I’ll struggle through it until I understand and may tweak a bit.

    Like

  2. Hi, thanks for this. Quick question though. If i enter a URL including a ‘=’ sign the script is not working
    part of the URL is this domain.com/sp?id=kb_article_view&sys_kb_id=927c4d1

    the error is this:
    VERBOSE: Error, could not read .\Config-file.xml
    VERBOSE: Error message: Cannot convert value “System.Object[]” to type “System.Xml.XmlDocument”. Error: “‘=’ is an
    unexpected token. The expected token is ‘;’. Line 11, position 106.”

    I see in your screenshot that the URL is pointing to a similar URL. How did you manage to get it working?

    Like

  3. Hi, Thanks for the script,
    I am not so good with scripting can you help to replacing action button and dismiss button with Restart now and Pick a time button.

    Like

Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.