For me, it's x09_105... I'd have to look further to see what the differences are.
You can get it this way also
#!/bin/bash
server=$(osascript -e "tell application "Microsoft Outlook" to set x to server of default account")
echo "server is $server"
But Outlook needs to be running for that to work (it'll open outlook if it's not running). You may want to look to see if Outlook is running, then execute that command if it is....? or you can keep digging into those Data Records files... Good luck!
Thank you @thoule
That will work perfectly for what i need, i've popped in a check to see if the user is logged in, check if Outlook is open and also write to a text file.
I'm sure there's a much tidier way to script this... but it works for now
!
#!/bin/sh
#Is machine at login screen or logged in as local admin
loggedInUser=$( stat -f%Su /dev/console )
if [[ $loggedInUser = "root" ]] || [[ $loggedInUser = "localadmin" ]] || [[ $loggedInUser = "localadmin2" ]]; then
#Does info file exist
if [ -f /Library/Application Support/JAMF/bin/ExchangeServer.txt ]; then
ExchangeServer=`cat /Library/Application Support/JAMF/bin/ExchangeServer.txt`
#Yes
echo "<result>$ExchangeServer</result>"
exit
else
#No info file or user is not logged in
echo "<result>EA not updated</result>"
exit
fi
fi
#--- user is logged in
#is Outlook open ?
SERVICE='Microsoft Outlook'
if pgrep -xq -- "${SERVICE}"; then
server=$(osascript -e "tell application "Microsoft Outlook" to set x to server of default account")
echo "$server" > /Library/Application Support/JAMF/bin/ExchangeServer.txt
else
echo "<result>EA not updated</result>"
exit 0
fi
ExchangeServer=`cat /Library/Application Support/JAMF/bin/ExchangeServer.txt`
echo "<result>$ExchangeServer</result>"