Outlook email address extension attribute not working

New Contributor III

Have a script that does the following:

  • Checks to see if Microsoft Outlook is installed. If it is..
  • Utilizes applescript to determine if Outlook is running. If it is ..
  • Tell me the username of the microsoft exchange account is being used.
  • If Outlook isnt running, it will report back "Offline"

Tested it as a regular script and works as intended but in in JAMF it doesnt display anything. Neither the email address nor 'offline'. Any thoughts on what isnt right? 


if [ -e "/Applications/Microsoft Outlook.app" ]; then
useremail=$(/usr/bin/osascript <<'EOF'
if application "Microsoft Outlook" is running then
	tell application "Microsoft Outlook"
		user name of every exchange account
	end tell
	return "Offline"
end if

Echo "<result>$useremail</result>"



Contributor III

Remember that scripts run as root by default in Jamf.  I'm not enough of an AS expert to know if you could get that part of the script to look into userspace, but you could run the entirety of the script (not just the AS) as the logged-in user, ie

currentUser=$(stat -f %Su /dev/console) 

or similar (don't parse ls).