Score:0

Add office365 Sharepoint library to OneDrive Sync

hm flag

I'm working on automating the OneDrive setup for new computers, and I'm new to this kind of thing.

I need to automate the Sharepoint shared library setup on the user computer. This way the user has all the shared librairy in the Windows file explorer. This Sharepoint is provided with our Office365 account.

I read the Microsoft documentation and build the URL with the necessary data needed as explained in the part “Auto-configure SharePoint site synchronization”.

But there is a problem in my powershell script that I don't understand.

When I run the powershell command Start-Process "odopen://sync/?siteId[...]", the OneDrive window opens and I have to set up the account. But at the end of the process, the only thing synchronised with OneDrive is the user's personal (business) OneDrive, and not the shared librairy.

The folder created by OneDrive is : C:\Users%username\OneDrive -
And the one I want to have is : C:\Users%username<tenant name><Shared Librairy>

It's like OneDrive doesn't care about all the parameters passed in the URL.

FYI, I run this script in a fresh Windows 10 VM.

Thanks for your help

Score:0
hm flag

So, we must URL encode paramters like below :

Add-Type -AssemblyName System.Web
$WebURL = [System.Web.HttpUtility]::UrlEncode("https://plop.sharepoint.com")
$SiteID = [System.Web.HttpUtility]::UrlEncode("{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
$WebID = [System.Web.HttpUtility]::UrlEncode("{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}")
$ListID = [System.Web.HttpUtility]::UrlEncode("{xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx}")
$WebTitle = [System.Web.HttpUtility]::UrlEncode("PLOP")
$ListTitle = [System.Web.HttpUtility]::UrlEncode("Folder")
$UserName = [System.Web.HttpUtility]::UrlEncode("[email protected]")

Write-Output "Configure OneDrive"
$odopen = "odopen://sync/?onPrem=0&webTemplate=68&libraryType=4&siteId=" + $SiteID + "&webId=" + $WebID + "&webUrl=" + $webURL + "&listId=" + $ListID + "&userEmail=" + $UserName + "&webTitle=" + $WebTitle + "&listTitle=" + $ListTitle

Start-Process $odopen

That's all...

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.