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.
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:
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.
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
Or any powershell endpoints for that matter. No good way to proactively monitor user workstations to ensure sync is running and healthy.