Forum Discussion
Ivan54
Jan 25, 2018Bronze Contributor
Need PowerShell Script to remove broken inheritance
Hi,
I'm having an issue with a specific document library in SharePoint Online that is being synced to a department.
This document library resides in a Classic SharePoint Site, turned into modern view manually.
For some reason every time a user creates a document or folder in that document library (through the Windows 10 v1709 Windows Explorer - OneDrive Sync) the permission inheritance on that file/folder is broken and only the CREATOR has permissions. Therefore nobody else sees those files and folders.
Now I need a PowerShell script that will remove all the broken inheritances from a specific document library in SharePoint Online.
I've searched online, but only found scripts that seem to work with old SP onPrem solutions.
- Rob EllisBronze ContributorI've used this one successfully with SPO in the past:
https://gallery.technet.microsoft.com/office/Delete-unique-permissions-8fd47022- Ivan54Bronze ContributorThanks Rob,
I think this should work, but unfortunately PowerShell ISE crashes after a few minutes.
The DocLib has over 6000 items, maybe that is the reason.
I'd like to limit the script to items with broken inheritances instead of the full DocLib to maybe work around the crash.
Can you help me incorporate this information into the script?
Arleta Wanat
It resets the permissions for every item. If you want to check only the ones with unique permissions, add an if condition to check for HasUniqueRoleAssignments property.
A very good explanation on how to load the values for the property is available here:
https://sharepoint.stackexchange.com/questions/126221/spo-retrieve-hasuniqueroleassignements-property-using-powershell- I've had issues with PowerShell ISE locking up on my Win 10 PC. I switched over to the PowerShell console available through Visual Studio Code and have not had any crashes since. https://code.visualstudio.com/