Is it possible to have a Power Automate Flow create a onedrive sync of a specific folder? Or PowerShell script?

Rohman, William T 20 Reputation points
2024-04-25T18:07:58.09+00:00

Is it possible to create a Power Automate Flow to do the following:

  1. Click a button
  2. Power Automate form appears
  3. Form requests a name of a folder from the user.
  4. User enters an existing folder name in a SharePoint Online Library.
  5. OneDrive Opens if not already.
    1. If there is an existing directory for this sync on the local machine this one is used.
    2. If there is Not an existing directory for this sync on the local machine one is created.
  6. It creates a sync to this folder automatically, without further input from the user.

I was looking to see if there is a way to keep the user from having to do any of this manually and try and eliminate any potential user mistakes in the sync process.

Or, is this possible through PowerShell PnP, does anyone know? 

If this is possible I would further investigate automating process of "freeing up space" of the sync'd directory, stopping the sync, and delete the 'local' OneDrive copy of the directory.  Again with the intent of minimal user input as possible, and remove potential user mistakes. 

Thank you All for your Time and assistance, Peace, 

SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
9,897 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,177 questions
{count} votes

Accepted answer
  1. Haoyan Xue_MSFT 20,986 Reputation points Microsoft Vendor
    2024-05-01T02:00:41.8266667+00:00

    Hi @Rohman, William T ,

    I'm glad to hear you solve the problem, if you have any issue about SharePoint, you are welcome to raise a ticket in this forum.I would make a brief summary of this thread:

    Issue Symptom:

    Create a onedrive sync of a specific folder using power automate or powershell.

    Current status:

    The issue has been solved. Shawn's Suggestion Works! Using the following powershell:

    $sharepointLibraryURL = "https://yourorganization.sharepoint.com/sites/YourSite/Shared Documents/YourLibrary"
    
    Path to OneDrive executable
    
    $oneDrivePath = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"
    
    Start syncing the SharePoint library with OneDrive
    
    Start-Process -FilePath $oneDrivePath -ArgumentList "/url:$sharepointLibraryURL"
    
    

    I'm going to turn Shawn's comment into an answer.

    You could click the "Accept Answer" button for this summary or Shawn's answer to close this thread, and this can make it easier for other community member's to see the useful information when reading this thread. Thanks for your understanding!

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. Shawn Collins 615 Reputation points
    2024-04-26T11:09:55.78+00:00

    Gotcha, that makes sense and would be tedious. Try this Powershell:

    URL of the SharePoint library to sync

    $sharepointLibraryURL = "https://yourorganization.sharepoint.com/sites/YourSite/Shared Documents/YourLibrary"

    Path to OneDrive executable

    $oneDrivePath = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe"

    Start syncing the SharePoint library with OneDrive

    Start-Process -FilePath $oneDrivePath -ArgumentList "/url:$sharepointLibraryURL"

    1 person found this answer helpful.
    0 comments No comments

  2. Rohman, William T 20 Reputation points
    2024-04-30T12:36:16.11+00:00

    Shawn Collins Apr 26, 2024, 7:09 AM Gotcha, that makes sense and would be tedious. Try this Powershell: URL of the SharePoint library to sync $sharepointLibraryURL = "https://yourorganization.sharepoint.com/sites/YourSite/Shared Documents/YourLibrary" Path to OneDrive executable $oneDrivePath = "$env:LOCALAPPDATA\Microsoft\OneDrive\OneDrive.exe" Start syncing the SharePoint library with OneDrive Start-Process -FilePath $oneDrivePath -ArgumentList "/url:$sharepointLibraryURL"

    Shawn's Suggestion Works!

    0 comments No comments