Fix OneDrive for mac.

If you're like me and use Office365 on a Mac, you probably also have used OneDrive. For awhile, I had certain OneDrive folders syncing across at least 3 computers (2 were Mac), but then I started to have some issues on 1 of them. My primary symptom was that when I tried to start OneDrive, it would appear to launch, but then the cloud icon in the top tray would never darken - to indicate it was running successfully - and would never offer any options in it's menu other than quit.

I found nothing online that addressed my symptoms, or more generally provided relevant troubleshooting steps, so I hope that if you've found this post, and have a OneDrive application that is misbehaving, that you'll find this useful.

After at least a week of email exchange with Outlook support (), I finally got an email with 5 suggestion bullets - the first 4 of which were entirely useless, but the 5th was a jackpot:

Reset OneDrive:
1. Quit the OneDrive application if it’s running.
2. Delete ~/Library/Containers/com.microsoft.OneDrive-mac.
3. Delete ~/Library/Containers/com.microsoft.OneDriveLauncher (if it exists).
4. Restart your Mac, or open Terminal and run the command killall -SIGTERM cfprefsd.
5. Restart the OneDrive application.

You may have seen, in my other posts, that I'm a bit of a PowerShell hack, but I wouldn't consider myself proficient in bash. But I looked at these 5 steps and thought, that can't be so hard.

So here's the final product, available for your use and/or scrutiny vit github.

https://github.com/bcdady/MyScripts/blob/master/Reset-OneDrive-Mac.sh

#!/bin/sh
############################################################################
# Reset a OneDrive app which is misbehaving, such as not sync'ing.
# The following steps were recommended by Microsoft OneDrive support, and tested successful by the author,
# with no side effects, othen than having to re-sign in to the OneDrive app, and reselecting certain directories to exclude form sync
#
#  Steps performed by this script, in order:
# Quit the OneDrive application if it's running.
# Delete ~/Library/Containers/com.microsoft.OneDrive-mac.
# Delete ~/Library/Containers/com.microsoft.OneDriveLauncher (if it exists).
# Run the command killall -SIGTERM cfprefsd.
# Restart the OneDrive application.
############################################################################
clear
echo ""
echo "*** Reset OneDrive for Mac ***"
echo ""
sleep 1
echo "Quit the OneDrive process(es)"
osascript -e 'quit app "OneDrive"'
sleep 1

echo "Delete ~/Library/Containers/com.microsoft.OneDrive-mac"
rm -Rf ~/Library/Containers/com.microsoft.OneDrive-mac
sleep 1

echo "Delete ~/Library/Containers/com.microsoft.OneDriveLauncher" # (if it exists)
rm -Rf ~/Library/Containers/com.microsoft.OneDriveLauncher
sleep 1

echo "Restart the OneDrive application"
killall -SIGTERM cfprefsd
sleep 1
open -a OneDrive

I hope that if you find it useful, you can make time to comment (or otherwise -twitter, github, etc.) let me know if this helped you.