Skip to main content

Hi all



Can anyone recommend a way to get the server address from Outlook 2011 ?



I can see the server address is stored in a binary file here



~/Documents/Microsoft User Data/Office 2011 Identities/Main Identity/Data Records/Exchange Accounts/0T/0B/0M/0K/x09_104.olk14ExAccount


but i'm not 100% sure that location is constant on all the Macs and i also haven't found a way yet to extract the server address as it's a binary and grep doesn't seem to play well with it.



any other ways to skin this poor cat ?

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>"

Reply