ODOPEN sync issue

tim christiansen 1 Reputation point
2022-10-18T11:58:02.193+00:00

I have synced a sharepoint site folder using powershell using ODOPEN, which works fine right after syncing.

Issue is when I restart app / computer, then it removes my synced sharepoint folder from synced accounts.

As a note, whenever this happens, the following key gets deleted: HKEY_CURRENT_USER\Software\Microsoft\OneDrive\Accounts\Business1\Tenants\company name\KeyNameOfFolder
But the syncengine regkey stays at: Computer\HKEY_CURRENT_USER\Software\SyncEngines\Providers\OneDrive\KeyValue

ODOPEN string used: odopen://sync/?siteId=&webId=&listId=&folderId=&userEmail=&webUrl=&folderUrl=&listTitle=&webTitle=

Any ideas? :)

SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,431 questions
OneDrive Management
OneDrive Management
OneDrive: A Microsoft file hosting and synchronization service.Management: The act or process of organizing, handling, directing or controlling something.
1,405 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Tong Zhang_MSFT 9,246 Reputation points
    2022-10-19T06:12:44.32+00:00

    Hi @tim christiansen ,

    According to my research and testing, please try to use the following PowerShell code to sync a SharePoint site folder:

    $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)  
    

    More information for reference:
    how to sync a sharepoint 365 folder using a .bat or powershell?
    Syncing SharePoint Document Libraries on Non-Persistent Virtual Computers

    Hope it can help you. Thanks for your understanding.

    Note: Microsoft is providing this information as a convenience to you. The sites are not controlled by Microsoft. Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please make sure that you completely understand the risk before retrieving any suggestions from the above link.


    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    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.



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.