Hi there,
we are in the process of migrating users from one Office 365 tenant to another, and as part of the process we need to reset all Office apps running on macOS devices enrolled also in a new Jamf Instance. However, I am having some when resetting all Office apps on macOS devices. The old OneDrive volume is still visible in the side bar favorites in Finder.
I can get everything else working using Office-Reset and an additional line that I am running to remove the OneDrive folder from the user's home directory, but I can't get the old OneDrive volume removed from the side bar in Finder.
I have even tried uninstalling and reinstalling OneDrive.
Please note, I only want to remove a specific OneDrive volume from the Finder sidebar without affecting other favorites using a bash script, so resetting the plist is not an option for me as it will affect other favourite settings..
so far I have tried the below two scripts, but neither of them seem to do the trick.
Has anyone come across something like this before?
# Set the name of the OneDrive volume to remove
VOLUME_NAME="OneDrive - CompanayName"
# Use defaults to get the current sidebar favorites
SIDEBAR_FAVORITES=$(defaults read com.apple.sidebarlists favoriteitems)
# Check if the sidebar favorites contain the OneDrive volume
if [[ $SIDEBAR_FAVORITES == *$VOLUME_NAME* ]]; then
# Use sed to remove the OneDrive volume from the sidebar favorites
SIDEBAR_FAVORITES=$(echo "$SIDEBAR_FAVORITES" | sed "s/\\"$VOLUME_NAME\\"//")
# Use defaults to write the modified sidebar favorites back
defaults write com.apple.sidebarlists favoriteitems -array "$SIDEBAR_FAVORITES"
echo "Successfully removed $VOLUME_NAME from the Finder sidebar."
else
echo "$VOLUME_NAME not found in the Finder sidebar."
Second Script:
#!/bin/bash# Unmount the OneDrive volume
osascript -e 'tell application "Finder" to eject "OneDrive"'# Remove the OneDrive folder from the Finder sidebar
defaults delete com.apple.sidebarlists favorites | sed '/OneDrive/d' | defaults write com.apple.sidebarlists favorites -data "$(xxd -r -p)"