SharePoint Online: Grant Access to All Lists and Libraries with Unique Permission using PowerShell

Requirement: Grant Access to All Lists and Libraries with Unique Permission in SharePoint Online.

How to Set Permissions on All Lists and Libraries with Broken Inheritance?

We have a SharePoint Online site with a bunch of lists and document libraries uniquely permission-ed. How do we quickly find unique permission lists and add users or groups to them? Well, here is how:

  • Navigate to your SharePoint Online Site >> Click on Settings >> Site Settings 
  • On the Site Settings page, click on the “Site Permissions” link under the “Users and Permissions” group.
  • On the site permissions page, at the top, You’ll see “Some content on this site has different permission from what you see here. Click on the “Show these Items” link.
    grant access to lists with unique permission in sharepoint online
  • You’ll get a page with all lists and libraries which are using unique permission. If you want to grant permission to any of these lists, just click on the “Manage Permissions” link and provide the desired permission.
    sharepoint online grant access to all unique permissioned lists

BTW, if lists and libraries with unique permissions have any existing SharePoint group in it, we can add the new user to that group (E.g. “Site Member”) to make permissions simpler. However, that may not be the case always!

PowerShell to Provide Access to All Unique Permission-ed Lists and Libraries

While it’s straightforward to grant access to lists with unique permission, providing access to numerous lists through a web browser interface would be inefficient. So, Here is the PowerShell script to add a user or group to all lists with broken inheritance.

#Config Variables
$SiteURL = ""
$UserID = "[email protected]"
$GroupName = "Neo Site Owners"
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -UseWebLogin
#Get All Lists and Libraries
$Lists  = Get-PnPList -Includes HasUniqueRoleAssignments
$ExcludedLists = ("Preservation Hold Library", "Site Collection Images", "Style Library")

#Filter Lists with Unique Permission, Non-Hidden and Not In Excluded List
$UniqueLists = $Lists | Where {$_.HasUniqueRoleAssignments -eq $true -and $_.Hidden -eq $false -and $_.Title -notin $ExcludedLists}

#Iterate through each list 
ForEach($List in $UniqueLists)
    #Grant Edit permission on List to User
    Set-PnPListPermission -Identity $List -AddRole "Edit" -User $UserID 
    #Grant "Full Control" permission on list to SharePoint Group
    Set-PnPListPermission -Identity $List -AddRole "Full Control" -Group $GroupName

    Write-host "Granted Permissions on List:"$List.Title

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply