r/PowerShell • u/rexm3 • Jan 12 '26
Script Sharing PowerShell un-sync script
I'm looking for a customizable script to stop OneDrive from syncing specific SharePoint sites/libraries. Then after the sync has completely stopped, removing the local files remaining of that specific site. Does anybody have a script for this already or any tips on this?
I would like the option to hard code the specific libraries to un-sync as I might need to execute it using RMM software.
8
Upvotes
View all comments
Show parent comment
1
u/Dragennd1 Jan 12 '26
You can't rempve files from the computer just by breaking OneDrive sync, that's not how it works. OneDrive caches the files locally and maintains their versioning with the cloud. Once you break the sync, you must remove the remaining files manually. Simply calling Remove-Item on the files using Get-ChildItem -Recurse should be sufficient at that point.