Nine41 Consulting | Have You Ever Needed to Send a Notification or an Alert to Your Entire Organization?
apple, device management, dep, vpp, systems management, landesk, ivanti, lanrev, absolute, heat, mdm,
16455
post-template-default,single,single-post,postid-16455,single-format-standard,qode-quick-links-1.0,ajax_fade,page_not_loaded,,columns-3,qode-child-theme-ver-1.0.0,qode-theme-ver-11.0,qode-theme-bridge,wpb-js-composer js-comp-ver-5.1.1,vc_responsive
 

Have You Ever Needed to Send a Notification or an Alert to Your Entire Organization?

Have You Ever Needed to Send a Notification or an Alert to Your Entire Organization?

“SAP is currently experiencing a service interruption. IT is investigating.”

We’ve all had days, and unfortunately, as many, if not more, nights that have been interrupted with a business service disruption. And with that disruption, the onslaught of self-service incidents come rolling in.

Now, with a good Service Management tool that contains some sort of Noticeboard, we can publish such notifications to those that access the business service, but all to often and despite our best intentions, the incident submissions keep rolling in, flooding the help desk.

Well, as Mac administrators, you do have another tool in the bag that you may want to employ such circumstances, in addition to your Service Management noticeboard, and that is to leverage the Notification System or Alert System built into macOS. Not only is it easy to create the alerts and notifications, you can deploy them with your Systems Management tool; essentially giving you instant access to your users’ desktops.

Notifications

The best part about using Notifications is that they are subtle and unobtrusive. The Notification window pops up, makes a sound if you desire, and then slide off the screen within about 5 seconds. If the user needs to review or re-read the notification, the message can be accessed from their Notification Panel.

 

Unfortunately, the Notification panel does have its shortcomings. According to a discussion thread on Apple.com, the title is limited to 21 characters and the message body can only contain 57.  That’s 40% the size of a tweet, so you better be brief!

Alerts

To overcome the message size limitations for Notifications, you can remotely activate an alerts dialog box and use it instead of a system notification.

The only downside to the extra character space you get with an alert, is that is quite intrusive. When you trigger the alert dialog, it will display front and center, regardless of what the user is doing. While as an admin you can set a timing trigger to automatically dismiss the alert dialog, even if unacknowledged, it’s just not the best experience.

Now, depending on your situation, you may feel your alert should take precedence over anything your users could potentially be doing; such as sending out a campus wide alert regarding an active shooter.

 

Building Notifications and Alerts

To build these notifications and alerts, we’re going to use AppleScript. If you’re unfamiliar with AppleScript or would like additional information about it, beyond what I cover below, pull up Apple’s Mac Automation Scripting Guide.

Notifications

A macOS notification consists of four parts; the title, the subtitle, the message body and the system sound. To build your alert and test it, open up Apple’s Script Editor found in your Applications > Utilities folder. Once open, copy and paste the text below into the editor and adjust as desired.  To test, just hit the play button on the menu bar.

display notification "SAP is currently experiencing a service interruption. IT is investigating" 
with title "Nine41 IT" subtitle "SAP Service Unavailable" sound name "Pop"

 

All of the text that comes after the display notification call is your message body.  Remember, you need to keep this to 57 characters or less.  Anything more than that will be lost.

After your message body, add in the text ‘with title’ and put in your title text in quotes.

If you desire to have a subtitle, add the text ‘subtitle’ followed by your information in quotes.

Finally, if you would like your notification to pop with a sound, add the text ‘sound name’ and enter the name of a sound file found in /System/Library/Sounds.  When you’re typing in the name of your chosen sound file, make sure you pay attention to the case as it is context sensitive.

Once you’re happy with your script, you need to export it as an application from the Script Editor. Just go to File > Export and from the dropdown in file format and select Application. You may also want to check the box to Run-only.  If you need to sign your apps, do so with your certificate as well.

Once it has been saved as an application, compress it and copy it to your package share so we can deploy it later.

 

Alerts

Creating the AppleScript to build a macOS alert dialog box is about as simple as a system notification, but it does have a few more parts to the puzzle.  Like the system notification, you’re going to provide the title and the message body.  With the alert dialog box, you won’t have the subtitle option, but do you do have the ability to add buttons and you can automatically dismiss the alert after a defined period of time.

Create a new file in Script Editor and copy and paste the text below into your new file, making adjustments as desired.

set theAlertText to "Nine41 IT" 
set theAlertMessage to "SAP Service Unavailable 

All SAP business services are experiencing a service interruption. IT is investigating and hope to have service restored by 2 PM today. Thanks in advance for your patience." 
display alert theAlertText message theAlertMessage as critical buttons {"OK"} default button "OK" giving up after 10 

In our dialog box script, there are essentially two sections. In the first section, you need to set your variables for the message and the title. ‘theAlertText’ variable is your title and ‘theAlertMessage’ is your message body. Notice I have carriage returns in my message body and those do translate into the alert dialog box. In essence, this lets you have the ability to create a subtitle of sorts if you desire.

In the second section, you’ll invoke the display alert command.  You will also specify the names of your buttons, you can have up to three of them and you can define which one will be the default.  Again, for more details, see Apple’s Mac Automation Scripting Guide.  The last item to add is the ‘giving up after’ time value, which is in seconds.

That’s it.  Hit the play button on your menu to test it out.  As outlined above, when you like the script the way it is, you need to export it as an application from the Script Editor. Do this by going to to File > Export and from the dropdown in file format and select Application.  You may also want to check the box to Run-only. If you need to sign your apps, do so with your certificate as well.

 

Once it has been saved as an application, compress it and copy it to your package share so we can deploy it later.

Deploying AppleScript with LANDESK Management Suite

When deploying any script with LANDESK, by default, it is silently executed by the agent.  In most scenarios, that is the behavior you want. For a notification or alert, however, that is the exact opposite behavior.  To overcome this, I had you export your script as an application. That way, when executed, it’ll run as an app and the user will see the notification or alert.

Therefore, all you need to do at this point is write a script that will download your Script Editor application and run it. We will still use SDClient in our script, giving us bandwidth controls and peer sharing. For more information on creating such scripts, see my blog post on efficiently transferring files with sdclient.

If you’d like, you can use my scripts below or download them from GitHub. In short, these two scripts have been designed to download, unzip and open the notifications and alerts. The scripts have been setup for variables, so make sure you adjust the path of your zipped AppleScripts, as well as their zipped and unzipped names. It really should be all that you need to tweak.

By the way, I’ve also included my AppleScripts in the GitHub repository.

Notification Script
#!/bin/sh

# NotificationLaunch.sh
# Created by Bennett Norton on 2/17/17.

#File to copy
#change this to match your hosted path, it needs to be http

packageName="displayNotificationAS.zip"
packageNameUnzipped="displayNotificationAS.app"
packageFilePath="http://bn-sgu-ldserver.ldlab.org/SoftwareDist/MacPackages"
packageToCopy="$packageFilePath"/"$packageName"

#Location to copy file to
#change this to match your destination path
destinationLocation=/Library/Application\ Support/LANDesk/sdcache/Notification

#Check to see if destination exists and if not, create it
if [ ! -d "$destinationLocation" ]; then
echo "Location doesn't exist. Creating directory"
mkdir $destinationLocation
echo "$destinationLocation created"
fi

#Download and execute command
#You shouldn't need to make any changes here
#-noinstall ensure the package does not get executed when downloaded
#-package is the source url path
#-destdir is the destination url path
/Library/Application\ Support/LANDesk/bin/sdclient -noinstall -package "$packageToCopy" -destdir "$destinationLocation"

unzip -o "$destinationLocation"/"$packageName" -d "$destinationLocation" 

open "$destinationLocation"/"$packageNameUnzipped"

exit 0

 

Alert Script
#!/bin/sh

# AlertLaunch.sh
# Created by Bennett Norton on 2/17/17.

#File to copy
#change this to match your hosted path, it needs to be http

packageName="displayAlertAS.zip"
packageNameUnzipped="displayAlertAS.app"
packageFilePath="http://bn-sgu-ldserver.ldlab.org/SoftwareDist/MacPackages"
packageToCopy="$packageFilePath"/"$packageName"

#Location to copy file to
#change this to match your destination path
destinationLocation=/Library/Application\ Support/LANDesk/sdcache/Alert

#Check to see if destination exists and if not, create it
if [ ! -d "$destinationLocation" ]; then
echo "Location doesn't exist. Creating directory"
mkdir $destinationLocation
echo "$destinationLocation created"
fi

#Download and execute command
#You shouldn't need to make any changes here
#-noinstall ensure the package does not get executed when downloaded
#-package is the source url path
#-destdir is the destination url path
/Library/Application\ Support/LANDesk/bin/sdclient -noinstall -package "$packageToCopy" -destdir "$destinationLocation"

unzip -o "$destinationLocation"/"$packageName" -d "$destinationLocation" 

open "$destinationLocation"/"$packageNameUnzipped"

exit 0

Remember, after you save your shell script, set the execute permissions on it by opening terminal and running the command below and then copy it to your package server share.

chmod +x /path/to/your/script.sh

With the script ready, you now need to build the software package to distribute to the Macs.  To do this, follow these steps below:

  • From the LANDESK Console, open Tools > Distribution > Distribution Packages
  • Inside the menu tree, highlight My Packages or Public Packages and then select the New Package button on the menubar and select New > Macintosh > Macintosh Agent
  • Give the package a name, description and point the primary file to the .sh file created previously
  • Fill out the Metadata details if desired
  • Save the package
No Comments

Post A Comment

ARE YOU READY TO GET STARTED?
Please fill out your information, and a specialist will reach out to discuss our services in more details.
Your Information will never be shared with any third party.
        
Free Training Videos
Register to gain access to all of our free content.
YOUR PHONE
YOUR NAME
YOUR EMAIL
        
Get Started
Provide us your contact information and we will reach out as quickly as possible.
YOUR PHONE
YOUR NAME
YOUR EMAIL
        
Additional Questions?
Provide us your contact information and we will reach out as quickly as possible.
YOUR PHONE
YOUR NAME
YOUR EMAIL
        
Pay by PO?
Provide us your contact information and we will reach out to help you sign up by PO.
YOUR PHONE
YOUR NAME
YOUR EMAIL
Subscribe Now
Subscribing to our site gives you access to our Apple Admin 101 training videos as well as allowing us to notify you of each new blog post we release.
YOUR PHONE
YOUR NAME
YOUR EMAIL
Pay by PO
Send us your contact information and we will reach out to help you sign up by PO.
YOUR PHONE
YOUR NAME
YOUR EMAIL
Additional Questions?
Send us your contact information and your questions and we will reach out as quickly as possible.
YOUR PHONE
YOUR NAME
YOUR EMAIL
YOUR QUESTIONS
Get Started
Provide us your contact information and we will reach out as quickly as possible.
YOUR PHONE
YOUR NAME
YOUR EMAIL
Free Training Videos
Subscribing to our site gives you access to our Apple Admin 101 training videos as well as allowing us to notify you of each new blog post we release.
FIRST NAME
LAST NAME
PHONE
EMAIL
Subscribe Now
Subscribing to our site gives you access to our Apple Admin 101 training videos as well as allowing us to notify you of each new blog post we release.
FIRST NAME
LAST NAME
PHONE
EMAIL