How to sync a folder from Sharepoint to a Macbook using Business OneDrive? (Script)

The script should be run after we sign into their outlook (Assuming that OneDrive will automatically pick up the sign in info from other MS apps).


The script should:

  • Open OneDrive and sync their personal OneDrive (Making sure to backup desktop and other local folders).
  • After personal OneDrive is synced, this script should initiate a sync of the shared drive.


I got this from somewhere:

#!/bin/bash  

# Define SharePoint Folder URL
url="CompanySharepointUrl"  

# username of current logged in user 
user=whoami  

# Set the sync location 
sync_location="/Users/$user/Library/Cloud Storage/CompanyName" 

# Prompt for OneDrive credentials 
echo "Please enter your OneDrive credentials:" 
read -p "Username: " username 
read -s -p "Password: " password echo  

# Install or update OneDrive for Business if not installed 
echo "Checking if OneDrive for Business is installed..." 
if [ ! -d "/Applications/OneDrive.app" ]; then     
     echo "OneDrive for Business is not installed. Please install it from the App Store or the Microsoft website."     
     exit 1 
fi  

# Sign in to OneDrive for Business 
echo "Signing in to OneDrive for Business..." 
/usr/bin/open -a "/Applications/OneDrive.app" 
sleep 5   # Wait for OneDrive to launch 

/usr/bin/osascript -e "tell application \"System Events\" to keystroke \"$username\" & return" 
sleep 1 
/usr/bin/osascript -e "tell application \"System Events\" to keystroke \"$password\" & return"   
sleep 5  # Wait for sign-in to complete  

onedrive --synchronize "$url"     # This part I should start to sync the folder to my mac. Does not work


How can I sync the folder to my mac?

Posted on Nov 10, 2023 11:42 AM

Reply

Similar questions

There are no replies.

This thread has been closed by the system or the community team. You may vote for any posts you find helpful, or search the Community for additional answers.

How to sync a folder from Sharepoint to a Macbook using Business OneDrive? (Script)

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.