Skip to content

Instantly share code, notes, and snippets.

@Chalcahuite
Created January 13, 2016 18:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Chalcahuite/1bb9987313122f9f8f4f to your computer and use it in GitHub Desktop.
Save Chalcahuite/1bb9987313122f9f8f4f to your computer and use it in GitHub Desktop.
Force Update Outlook 2016 OAB files
#!/bin/bash
# updateOAB.sh
# Deletes the .oab files in a User's Office 2016 profile to force a re-download of the Offline Address Book.
# version 1.0 2016-01-12
##Variables
#get user
User=$(python -c 'from SystemConfiguration import SCDynamicStoreCopyConsoleUser; import sys; username = (SCDynamicStoreCopyConsoleUser(None, None, None) or [None])[0]; username = [username,""][username in [u"loginwindow", None, u""]]; sys.stdout.write(username + "\n");')
#get current date minus 24 hours
dateMinus24h=$(date -v-86400S +%s)
#get last modified date of udetails.oab file
oabModifiedDate=$(stat -Ls /Users/"$User"/Library/Group\ Containers/UBF8T346G9.Office/Outlook/Outlook\ 15\ Profiles/Main\ Profile/Caches/*/IndexDirName_*/udetails.oab | awk ' { print $10 }' | awk -F= '{print $2}')
##Execute
# If the last modified date of the udetails.oab file is older than the current date minus 24 hours then delete all the .oab files to force a download.
echo "Determining whether last modified date of OAB is older than 24 hours ago."
if [[ ${dateMinus24h} -gt ${oabModifiedDate} ]]; then
rm -r /Users/"$User"/Library/Group\ Containers/UBF8T346G9.Office/Outlook/Outlook\ 15\ Profiles/Main\ Profile/Caches/*/IndexDirName_*/*.oab
echo "OAB last modified date is older than 24 hours. Deleting all .oab files to force a new download."
else
echo "OAB has been recently updated. No force update required. "
fi
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment