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

AxeWork 0 Reputation points
2023-11-10T16:03:36.3933333+00:00

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
Microsoft 365 and Office | SharePoint | For business | Windows
Microsoft 365 and Office | OneDrive | For business | Windows
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Emi Zhang-MSFT 30,046 Reputation points Microsoft External Staff
    2023-11-13T00:38:28.05+00:00

    Hi,

    I suggest you post this issue to OneDrive for Developer forum:

    https://techcommunity.microsoft.com/t5/onedrive-developer/bd-p/OneDriveDeveloper

    The reason why we recommend posting appropriately is you will get the most qualified pool of respondents, and other partners who read the forums regularly can either share their knowledge or learn from your interaction with us. Thank you for your understanding.


    If the response is helpful, please click "Accept Answer" and upvote it.

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.