Skip to main content
Solved

Script to delete Outlook and Teams cache

  • March 6, 2021
  • 4 replies
  • 58 views

Forum|alt.badge.img+3

I need some help and guidance with the cleanup of the Outlook and Teams caching. Sometimes it is needed to delete those. So i made a script and want to publish is througt the selfservice App. So if our servicedesk advices someone to delete the cache, it can be done by the user. However, my scripting is not that great.

I want to present a popup with 3 choices to the user. Clear Outlook cache, clear Teams cache or quit. The latter one if the user is curious :-)

This is what i have so far but it errors out. What am i doing wrong or is there a better solution to this problem?

#!/bin/bash
# 
#
# Clean up script!
#
# Task - Clear outlook address cache list!
# Task - Clear Teams caching!
#
#
#echo on if needed
#set -x

SURETY="$(osascript -e 'display dialog "Delete the cache files?" buttons {"Teams", "Outlook", "Cancel"} default button "Cancel" with icon stop')"

if [ "$SURETY" = "button returned:Outlook" ]; then
    echo "Fine, let's delete some Outlook caching."
    cd ~/Library/Group Containers/
    find . -name "*.olk15RecentAddresses" -type f|xargs rm -f
fi

else if [ "$SURETY" = "button returned:Teams" ]; then
    echo "Fine, let's delete some Teams caching."
    rm -rf ~/Library/Caches/com.microsoft.teams
    rm -rf ~/Library/Application Support/Microsoft/Teams/Application Cache/Cache
    rm -rf ~/Library/Application Support/Microsoft/Teams/blob_storage
    rm -rf ~/Library/Application Support/Microsoft/Teams/Cache
    rm -rf ~/Library/Application Support/Microsoft/Teams/databases
    rm -rf ~/Library/Application Support/Microsoft/Teams/GPUCache
    rm -rf ~/Library/Application Support/Microsoft/Teams/IndexedDB
    rm -rf ~/Library/Application Support/Microsoft/Teams/Local Storage
    rm -rf ~/Library/Application Support/Microsoft/Teams/tmp
end if

else if [ "$SURETY" = "button returned:Cancel" ]; then
    echo "Nothing to do, let's quit."
end if

# Exit
exit 0

```

Best answer by pbowden

You might want to check out https://office-reset.com/macadmins

Thanks, Paul.

4 replies

Forum|alt.badge.img+12
  • Valued Contributor
  • Answer
  • March 6, 2021

You might want to check out https://office-reset.com/macadmins

Thanks, Paul.


mickl089
Forum|alt.badge.img+11
  • Valued Contributor
  • March 8, 2021

Best IT Support tool ;-)


Jason33
Forum|alt.badge.img+13
  • Honored Contributor
  • March 8, 2021

+1 for @pbowden and Office Reset. Its helped a few users in our environment.


Forum|alt.badge.img+1
  • New Contributor
  • March 10, 2021

Really magnificent tool! Thank“s a lot!