Scripts run as root when executed via the JSS.  This caused problems when trying to send notifications using terminal-notifier to users because root does not have a NotificationCenter instance, so any script using terminal-notifier would hang.  The trick to get around that is to run the command as the user.

I have been converting a lot of my shell scripts over to Python as it is more flexible and powerful.  This is script I wrote to send notifications while running as root.

#!/usr/bin/python
#-----------IMPORTS----------
import sys,pwd,os
import subprocess
from platform import mac_ver

#----------VARIABLES---------
v, _, _ = mac_ver()
v = float('.'.join(v.split('.')[:2]))

# Use Casper parameters 4-7
title = sys.argv[4]
subtitle = sys.argv[5]
message = sys.argv[6]
group = sys.argv[7]

#------------------------------		
#-------BEGIN SCRIPT-----------
#------------------------------	
if (v == 10.9) or (v == 10.10):
	u = os.getlogin()
	if ( u == '_atsserver') or ( u == 'root'):
		print u + " owns the loginwindow--no notification will be sent."
	else:
		print u + " owns the loginwindow--sending notification..."
		pw = pwd.getpwnam(u)
		os.initgroups(u,pw.pw_gid)
		env={"TERM":"xterm","USER":pw.pw_name,"HOME":pw.pw_dir,"SHELL":pw.pw_shell,"LOGNAME":pw.pw_name,"PATH":"/usr/bin:/bin:/opt/bin"};
		os.setgid(pw.pw_gid);
		os.setuid(pw.pw_uid);
		os.execve('/Applications/Hopkins Tech Support.app/Contents/MacOS/notifier',["","-title",title,"-subtitle",subtitle,"-message",message,"-group",group],env);
else:
	print "Notifications not supported version " + str(v)