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:

  1. Navigate to your SharePoint Online Site >> Click on Settings >> Site Settings.
  2. On the Site Settings page, click on the “Site Permissions” link under the “Users and Permissions” group.
  3. 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
  4. 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 them, 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!

Granting access to all lists and libraries in SharePoint Online can be a time-consuming task when done manually. However, by using PowerShell, you can automate this process and grant access to multiple lists and libraries at once. Let’s go through the steps of connecting to SharePoint Online using PnP PowerShell, and then how to grant access to all lists and libraries on a SharePoint Online site.

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

While granting access to lists with unique permission is straightforward, 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 = "https://crescent.sharepoint.com/sites/Neo"
$UserID = "Salaudeen@crescent.com"
$GroupName = "Neo Site Owners"
 
#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Interactive
 
#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
}

My related post on Grant Permission to All Items in a List in SharePoint Online using PowerShell

Conclusion

In summary, granting access to all lists and libraries in SharePoint Online can be a time-consuming task when done manually, but by using PowerShell, you can automate the process. By connecting to SharePoint Online using PnP PowerShell, you can use the appropriate cmdlets to grant access to multiple lists and libraries at once. This can be a powerful tool for IT professionals and administrators, allowing them to manage SharePoint Online more efficiently. It’s important to note that you must have the necessary permissions to access SharePoint Online and perform the actions you want to perform. By following this guide, you can easily grant access to all lists and libraries on a SharePoint Online site.

Salaudeen Rajack

Salaudeen Rajack - SharePoint Expert with Two decades of SharePoint Experience. Love to Share my knowledge and experience with the SharePoint community, through real-time articles!

Leave a Reply

Your email address will not be published. Required fields are marked *