Script to delete Outlook and Teams cache

jeroenkahle
New Contributor II

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

```

1 ACCEPTED SOLUTION

pbowden
Contributor III

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

Thanks, Paul.

View solution in original post

4 REPLIES 4

pbowden
Contributor III

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

Thanks, Paul.

mickl089
Contributor III

Best IT Support tool ;-)

Jason33
Contributor III

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

conadys
New Contributor

Really magnificent tool! Thank´s a lot!