Outlook 2011 - Removing Non-Currenty Identities script

Pascal_Sherman
New Contributor

Sorry for the typo in the title...

Anyone know where I could pull the name of the current outlook 2011identity that is being used to automate removing any older identities that were rebuilt?

Or better yet have written a script that does this?

Cheers,

Pascal

2 REPLIES 2

cvgs
Contributor II

Hi Pascal,

i had looked into this last year and found that the default identity's name had been stored in some proprietary binary file inside the Library folder. The exact location depends on the language version of Outlook 2011.

You should see the name of the identity in the output of

hexdump -C ~/Library/Application Support/Microsoft/Office/Einstellungen/Office 2011/Outlook Preferences

You would still have to see how you can reliably parse it out of that file.

Cheers
Christoph

Pascal_Sherman
New Contributor

Hey Christoph,

Fancy chatting with you here. I think I found a way to do this fairly safely, could probably need a bit of a clean up and a second set of eyes. Haven't added multi language functionality to this yet. The hexdump idea was the right direction to take but it leaves an extra leading character or two now and again,

xxd /Users/$u/Library/Application Support/Microsoft/Office/Preferences/Office 2011/Outlook Preferences | xxd -r

This works, but to be safe have gone with a double verification process where I am using the user folder with he most recently updated database inside. I've tested this through a few different ways but would love a second set of eyes and can think of an organization that could benefit from it's implementation if you agree / like the direction. Happy for you to edit / improve on the direction I've taken.

Pascal

!/bin/bash

Written by Pascal Sherman - pascal.sherman@us.redbull.com March 26th, 2016

This script is designed to delete all older Microsoft Outlook 2011 Identities.

Assumption is made that user is not storing any other data in this folder

Close Microsoft Outlook 2011 if it is running

if pgrep "Microsoft Outlook" > /dev/null
then echo "Running" killall "Microsoft Outlook" fi

Build List Of User Folders

UserList="$(ls -1 /Users)"

For Each User

for u in $UserList ; do #If User Folder Has Outlook 2011 Identities if [ -d /Users/$u/Documents/Microsoft User Data/Office 2011 Identities/ ]; then

#Change to Identities Folder cd /Users/$u/Documents/Microsoft User Data/Office 2011 Identities/

#Save latest Identity to a variable latestprofile=find . -type f -name "Database" -print0 | xargs -0 stat -f "%m %N" | sort -rn | head -1 | cut -f2- -d" " | sed 's/..//' | sed 's/.........$//'

echo "Profile by directory listing" $latestprofile"

#Compare latestprofiles with preferences config file for accuracy

preferences=xxd /Users/$u/Library/Application Support/Microsoft/Office/Preferences/Office 2011/Outlook Preferences | xxd -r echo "Profile from preferences files: $preferences"

if [[ "$preferences" == "$latestprofile" ]]; then

#Move Identity to Safety mv "/Users/$u/Documents/Microsoft User Data/Office 2011 Identities/$latestprofile" ..

#Delete the remaining profiles rm -rf *

#Move Identity Back mv "/Users/$u/Documents/Microsoft User Data/$latestprofile" "/Users/$u/Documents/Microsoft User Data/Office 2011 Identities/"

else echo "$latestprofiles and the identity listed in the prefrences file do not match" fi fi
done