Lars Olsen, Consultant
  Toast Notifications: This blogpost will help you to educate your users through Windows Toast messages, but the focus of this blog is to teach users to reboot more often – since that still is the way to install big critical updates in Windows 10.

Challenge

We all know that creeping sensation, when Microsoft releases a new critical patch to Windows, and it requires a reboot to finalize the installation, and the mob of users ignores your repeated politically correct formatted messages on the intranet. As administrators we must admit that what seems logical to computer wizz’ like us, is absolutely irrelevant to the average user, and most users, or opponents, are very average.

Goal

What if you could inform a specific user, that he/she is violating company policy with their ignorant behavior. Wouldn’t it be nice if you could put a sign in the face of the offender, without spamming the intranet with warnings to every user in the company? This is the smart bomb of user education utilizing PowerShell and Windows Toast notifications.

Prerequisites

First of we need to get some prerequisites straight, and there isn’t much to it. The only thing you need is Windows PowerShell ISE. For distribution in your company I recommend the World’s best software deployment tool CapaInstaller from CapaSystems.

Scope

This is only intended for Windows 10 but is also supported on Windows 7 – with the latest service pack. Are you ready? Here we go.

How to

Windows keeps track of how many seconds the current session has been running, it also tracks how many times the system has been booted.

To find out how long the current session has been running, we need to do some PowerShell WMI trickery.

$uptime = [int]((get-date)-[system.management.managementdatetimeconverter]::todatetime((get-wmiobject -class win32_operatingsystem).Lastbootuptime)).TotalSeconds

Now we know how many seconds the current session has been running for, but you would confuse the users if you presented them with this message:

More user-friendly time format

To make the time format more user-friendly, we need to do some low-tech PowerShell wizardry.

$days = New-TimeSpan -Seconds $uptime
$days = [String]$days
$days = $days -replace ‘^(.*?):(.)()’,’$1 hours $2′
$days = $days -replace ‘\.’,’ days ‘
$days = $days -replace ‘\:’,’ minutes ‘
$days = “$days seconds”

We convert seconds to a timespan, afterwards we do some replacing and adds text to make it nice and pretty. If you don’t like the way I’ve done the replacing/addition of text, then I encourage you to explore the many ways you can modify variables with PowerShell.

Modified code – from me to you

And now for the fun part – presenting the information in the toast message. The code below is copied and modified from Microsoft, and a full guide to creating custom toast messages can be found here. To include the modified time format from the variable $days in the body text, I use the variable below.

$BodyText = ‘Your computer has not been rebootet in ‘+ $days + ‘. Please reboot your computer as soon as possible.’

Modify this line in the script, to change the icon used in the toaster.

To modify the text on the button, edit the line below.

<action activationType=”background” content=”Understood – i’ll get it done!” arguments=”later”/>

This is how the new toast message looks:

You can add a check in the script to avoid warning users that have recently rebooted their computer.

Information: If the threshold for displaying the warning is a week, a week is 604800 seconds long.

Toast notifications can be used for many things, such as warning users about coming updates, missing reboot or too many files located on the desktop.

Have fun educating your users .

Below is the entire script. Remember to put a logo.png file in the “c:temp” folder, or edit the script use another file.

The entire script

$app = ‘{1AC14E77-02E7-4E5D-B744-2EB1AE5198B7}\WindowsPowerShell\v1.0\powershell.exe’

 

[Windows.UI.Notifications.ToastNotificationManager, Windows.UI.Notifications, ContentType = WindowsRuntime]

 

$Template = [Windows.UI.Notifications.ToastTemplateType]::ToastImageAndText01

 

#Gets the Template XML so we can manipulate the values

 

[xml]$ToastTemplate = ([Windows.UI.Notifications.ToastNotificationManager]::GetTemplateContent($Template).GetXml())

 

[xml]$ToastTemplate = @”

 

<toast scenario=”reminder” launch=”app-defined-string”>

<visual>

<binding template=”ToastGeneric”>

<text>gsToastHeader</text>

<text>gsToastText</text>

<image placement=”AppLogoOverride” src=”C:\Temp\logo.png” />

</binding>

</visual>

<actions>

<action activationType=”background” content=”gsButtonText” arguments=”later”/>

</actions>

</toast>

“@

 

$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument

$ToastXml.LoadXml($ToastTemplate.OuterXml)

$notify = [Windows.UI.Notifications.ToastNotificationManager]::CreateToastNotifier($app)

$notify.Show($ToastXml)

 

Download the free Whitepaper

 

"From operations to strategy"

 

You’re very likely facing this every day—a requirement for increased automation throughout the organization in order to raise competitiveness and also increase user satisfaction. That’s a difficult balancing act, and only few people succeed.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download the free Whitepaper regarding Digital Employee Analytics

 

"Employees are (also) the real success factor in the digital era"

 

In today’s digital world, employees build their careers on the ever-changing opportunities presented to them. So, competitiveness requires more from companies than ever before — you need to present your corporation as attractive as possible to existing as well as future employees.

Therefore, you need to incorporate the Employee Experience, which includes all aspects of the relation between the employee and the employer.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download the free Whitepaper

 

"How to select the right software provider"

 

Software providers abound, and very likely they will call you again and again wanting to present their solutions.

CapaSystems has made a brief guide with concrete advice on what you need to be aware of when you contemplate switching software providers or wish to integrate a new system in your organization.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download a free Whitepaper regarding the CIOs role in the future

 

"CIO as business developer"

 

It is crucial that businesses’ CIOs are able to identify, select and evaluate the IT services that provide maximum insight and increase growth and productivity. That requires tools that provide up-to-date operational insight into services’ functionality and stability.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

User Experience

Download free whitepaper regarding performance issues and end user simulation

 

"Solve your performance issues with end user simulation"

 

A recent study showed that Danish employees waste an average of 144 hours a year on slow computers. To a company of 500 employees, that is hundreds of thousands of Danish kroner. This whitepaper describes how you can minimise waiting time by having your IT provider comply with your service agreements.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download free Whitepaper from CapaSystems regarding performance issues and how to awoid wasting time

 

"Analyze infrastructure and use time efficiently"

 

Performance problems and long login times can easily cost businesses and organizations time that corresponds to several full-time jobs every year. It can be hard to identify the roots of the problems with traditional solutions.

End-user performance monitoring, however, provides an overview that covers the entire infra-structure – from end users to network and server applications. That provides an accurate, factual basis for correcting current problems and for nipping future problems in the bud.

 

Download the free Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download free whitepaper regarding BYOD

 

"Bring Your Own Device?"

 

Mix of personal and business applications on same IT devices makes IT departments worry.

But what about the security of your company in this universe of personal and business apps provided by a Bring Your Own Device (BYOD) culture?

 

 

 

Download the white paper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download free whitepaper regardingShadow IT

 

"Cast new light on Shadow-IT"

 

It’s a challenge when employees and business units purchase technology and IT services without involving the IT department. You easily lose perspective of finances, agreements and where important information is located –and if you’re not able to name who’s responsible for support from day one, a service outage risks being interpreted as internal trouble, even though the IT department has nothing to do with it.

 

 

Download the Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.

Download free whitepaper regarding security

 

"3 steps to secure the company against data sheft"

 

It is said that a chain is only as strong as its weakest link. Therefore, your weakest link in the IT systems will have to be properly secured. Here are our suggestions for three things that can secure your IT infrastructure.

 

 

Download the Whitepaper from CapaSystems and read more...

Thank you for signing up. You will receive a link to our free Whitepaper in your inbox.