OneDrive


Feedback by UserVoice

How can we improve the OneDrive experience on Windows?

Pause Syncing with PowerShell

I would like a way to pause and unpause OneDrive syncing in PowerShell. This would be handy in PowerShell scripts that manipulate files. Sometimes the files get locked if OneDrive is currently syncing them. I would like to be able to script the pause, make my file changes, then unpause when my script is finished.

52 votes
Vote
Sign in
Check!
(thinking…)
Reset
or sign in with
  • facebook
  • google
    Password icon
    Signed in as (Sign out)
    You have left! (?) (thinking…)
    Todd Klindt shared this idea  ·   ·  Flag idea as inappropriate…  ·  Admin →

    3 comments

    Sign in
    Check!
    (thinking…)
    Reset
    or sign in with
    • facebook
    • google
      Password icon
      Signed in as (Sign out)
      Submitting...
      • Anonymous commented  ·   ·  Flag as inappropriate

        Powershell and OneDrive do not get along well. In one script I open an Excel file, which is set to auto refresh some SQL data, then save the Excel file, close the workbook and quit the application with these last 3 lines:

        $workbook.Save()
        $Workbook.Close()
        $Excel.Quit()

        Works fine until the last line, which causes a sync failure in OneDrive, perhaps because it executes too quickly. If I leave the last line out, the file syncs fine.

      • John commented  ·   ·  Flag as inappropriate

        This would also help with scheduled backups using the Windows 7 Backup tool, which Files on Demand and OneDrive syncing have caused to fail in Windows 10 1803 and 1809. While I do not back up the OneDrive folders, the system image attempts to do so and fails.

      • James redmore commented  ·   ·  Flag as inappropriate

        Or any powershell endpoints for that matter. No good way to proactively monitor user workstations to ensure sync is running and healthy.

      Feedback and Knowledge Base