The process of building custom applications and tools that interact with Microsoft SharePoint, including SharePoint Online in Microsoft 365.
Thank you for reaching out to Microsoft Q&A
Based on your requirement, I think you can try the cmdlet above to see if it works, this PnP PowerShell cmdlet that resets unique permissions on all items (files and folders) in a SharePoint Online document library and restores inheritance from the parent library:
Connect-PnPOnline -Url "https://contoso.sharepoint.com/sites/YourSite" -Interactive
$LibraryName = "Documents"
$ListItems = Get-PnPListItem -List $LibraryName -PageSize 500
foreach ($Item in $ListItems) {
$HasUniquePermissions = Get-PnPProperty -ClientObject $Item -Property "HasUniqueRoleAssignments"
if ($HasUniquePermissions) {
Write-Host "Resetting permissions for item: $($Item.FieldValues['FileRef'])"
$Item.ResetRoleInheritance()
$Item.Update()
Invoke-PnPQuery
}
}
Additionally, you can read the reliable reference document that provides a detailed guide and sample scripts for removing unique permissions from SharePoint Online list items using PowerShell:
Link reference: SharePoint Online: Delete Unique Permissions for All Items in a List using PowerShell
Note: Microsoft is providing this information as a convenience to you. These sites are not controlled by Microsoft, and Microsoft cannot make any representations regarding the quality, safety, or suitability of any software or information found there. Please ensure that you fully understand the risks before using any suggestions from the above link.
Hope this helps.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.