Quantcast
Channel: Symantec Connect - Endpoint Management - Articles
Viewing all articles
Browse latest Browse all 706

Windows 10 Toast Notifications

$
0
0

Introducing Windows Toast Notifications

With the introduction of Windows 8 we were given a new way of creating notifications as part of Microsoft's Action Centre. These notifications allow Windows applications to display modern, unobtrusive notifications that are uniform in their design regardless of the invoking application. In this article I'm going to show you how you can deliver these notifcations with Altiris and how you can incorporate them into your own Altiris jobs.

Comparison

VB Message BoxWindows 10 Toast Notifications
Started-VB.PNGStarted-PS.PNG
Completed-VB.PNGComplete-PS.PNG

Windows Action Center

Action Centre is a centralized hub for all your notifications and alerts and provides a means of viewing past notifications. Each notification can specify an application ID which allows notifications to grouped. In the image below I have specified the application ID as "Altiris".

ActionCenter.png

Notification Powershell Script

Since the Symantec Management Agent now supports Windows 8 and Windows 10, we can now take advantage of these notifications and incorporate them into our own jobs and tasks.

These notifications are part of an API available in the .NET Framework which can be consumed by a simple Powershell script and pushed via the SMP to client's agents.

Create a new Powershell task in Altiris with the following content.

#
# Variables Defined in Altiris Task
#
$line1 = "%!Line1!%"
$line2 = "%!Line2!%"
$line3 = "%!Line3!%"

#$image must be a local file on the client's machine
$image = "%!Image!%" 
#$app is Action Center's Application ID
$app = "Altiris"

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

# 
# Load the Notification Template - ToastTemplateType enumeration see https://msdn.microsoft.com/EN-US/library/windows/a...
# 
# ToastImageAndText01
# ToastImageAndText02
# ToastImageAndText03
# ToastImageAndText04
# ToastText01
# ToastText02
# ToastText03
# ToastText04

$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())

$TextElements = $ToastTemplate.GetElementsByTagName('text')
foreach ($TextElement in $TextElements)
{
    switch ($TextElement.id)
    {
        '1' { $null = $TextElement.AppendChild($ToastTemplate.CreateTextNode($line1)) }
        '2' { $null = $TextElement.AppendChild($ToastTemplate.CreateTextNode($line2)) }
        '3' { $null = $TextElement.AppendChild($ToastTemplate.CreateTextNode($line3)) }
    }
}

#
# If the template requires an image, assign one.
#
if ($Template -like '*Image*')
{

    $ImageElements = $ToastTemplate.GetElementsByTagName('image')
    $ImageElements[0].src = "file:///$image"

}

           
$ToastXml = New-Object -TypeName Windows.Data.Xml.Dom.XmlDocument
$ToastXml.LoadXml($ToastTemplate.OuterXml)

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

$notify.Show($ToastXml)

Before you can run Powershell scripts on a client you either have to sign them or change the restriction policy. The latter is a lot easier to setup and Altiris give us two built in tasks to do this.

  1. Disable Powershell Signing Policy - A Command Script which runs powershell Set-Executionpolicy unrestricted
  2. Enable Powershell Signing Policy - A Command Script which runs powershell Set-Executionpolicy restricted

Below is an example of how you can include the signing tasks and the notification task into an existing job. As you can see, the notification parameters can also be defined here.

Altiris Task Notify2.PNG

I hope you find this useful.


Viewing all articles
Browse latest Browse all 706

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>