Forum Discussion
Syncing SharePoint Document Libraries on Non-Persistent Virtual Computers
TonyBryant great article, thanks for sharing.
I am testing the script but continually get an error after OneDrive launches:
Sorry, OneDrive can't add your folder right now. Please try again.
Have you come across this? I attached the error message as well
Thanks
JesseBoehm You will likely need to define your WebID in the script as the OP does not have that value defined in the script above
I was able to use this script with the additional modifications:
$WebID = ""
(you will need to supply the GUID for your specific WebID inside the quotes)
and then modify the odopen command to include the addition of the WebID:
I was unable to use the DomainServer, User, and UserEmail variables as we do not have RSAT for Active Directory deployed to all systems across our environment which is required to run the Get-ADUser command after loading the module in the script.
because of this I modified those areas to function differently. this is what I got working:
# Script for using OneDrive, with on-demand enabled, to sync SPO library at login
# Create a shortcut to this script in the user's Startup folder
# Target should be C:\Windows\System32\WindowsPowerShell\v1.0\powershell.exe -WindowStyle hidden -File "\\server\share\SyncSPOSite.ps1"
# Update variables below for the SPO library to sync. See this link for more info
# https://docs.microsoft.com/en-us/onedrive/deploy-on-windows?redirectSourcePath=%252fen-us%252farticle%252fdeploy-the-new-onedrive-sync-client-in-an-enterprise-environment-3f3a511c-30c6-404a-98bf-76f95c519668
$WebURL = "https://tenantname.sharepoint.com/sites/"
$SiteName = "MySiteName"
$SiteID = "{my Site GUID}"
$WebID = "{my Web GUID}"
$ListID = "{my List GUID}"
# Give Windows some time to load before getting the email address
Start-Sleep -s 20
$UserName = $env:USERNAME
$Domain = "@yourdomain.com"
# Use a "Do" loop to check to see if OneDrive process has started and continue to check until it does
Do{
# Check to see if OneDrive is running
$ODStatus = Get-Process onedrive -ErrorAction SilentlyContinue
# If it is start the sync. If not, loopback and check again
If ($ODStatus)
{
# Give OneDrive some time to start and authenticate before syncing library
Start-Sleep -s 30
# set the path for odopen
$odopen = "odopen://sync/?siteId=" + $SiteID + "&webId=" + $WebID + "&webUrl=" + $webURL + $SiteName + "&listId=" + $ListID + "&userEmail=" + $UserName + $Domain + "&webTitle=" + $SiteName + ""
#Start the sync
Start-Process $odopen
}
}
Until ($ODStatus)
There is probably a better way to pull the domain without the RSAT toolset, I just don't know it and this worked for the environment I plan on using it in.
-Jeremy