I want to break inheritance to a library and then remove members and visitors group. The code below works apart from the fact the library is still accessible but the content is not. The Quick launch also shows the link to the library, but no documents are visible. When I use the UI to break inheritance and remove the said groups, the library is not visible, so can't see why the code is not doing the same. Any ideas please?

# Break permissions inheritance for the library
$list.BreakRoleInheritance($true, $true)
Write-Host -ForegroundColor GReen "Unique permissions set on library" $listTitle

# Remove Member and Visitor Groups
foreach ($y in $SiteGroups) {
#$MemberGroup = $title + " Members"
#$VisitorGroup = $Title + " Visitors"
    if ($y.loginname -like "*Members") {
        $SiteMembers = $y.loginname
        Set-PnPGroupPermissions -Identity $SiteMembers -List $listTitle -RemoveRole "Contribute" -ErrorAction silentlycontinue
        Write-Host -ForegroundColor Green "Member Group removed!"
    If ($y.loginname -like "*Visitors") {
        $SiteVisitors = $y.loginname
        Set-PnPGroupPermissions -Identity $SiteVisitors -List $listTitle -RemoveRole "Read" -erroraction silentlycontinue
        Write-Host -ForegroundColor Green "Visitor Group removed!"


UPDATE 1 - Not sure but might be related to limited access, and the code not being ale to clear these out. get a yellow box with warning when i view library permissions: 'There are limited access users on this site. Users may have limited access if an item or document under the site has been shared with them. Show users. This library has unique permissions.'

1 Answer 1


Go to Site Settings->Site Collection Features, and enable the feature "Limited-access user permission lockdown mode".

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.