r/PowerShell • • 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

9 comments sorted by

View all comments

Show parent comment

1

u/rexm3 Jan 12 '26

removing the files isn't really the issue, that's pretty easy using PowerShell. the goal however is to stop the sync of specific libraries using a PowerShell script by any means. and then removing when the sync is gone. This way the files don't get deleted in the cloud version.

Also disabling the sync option in SharePoint itself doesn't solve this the way i like, because the folder is allowed to be synced just specific users need it removed. Hence wanting to script this for bulk actions on selected users. Using an RMM system I can execute a PowerShell script easily for the selected users.