SharePoint Online: PowerShell to Get List Permissions

Requirement: Get List Permissions in SharePoint Online using PowerShell.

How to Get List Permissions in SharePoint Online?

If you are a SharePoint administrator, you will need to get list permissions in SharePoint Online sooner or later. The process is not complicated, but there are a few steps that you need to follow. In this blog post, I will walk you through the process step-by-step for retrieving and displaying users’ permission levels on lists or libraries. We’ll also see how to get list permissions in SharePoint Online using PowerShell. Let’s get started!

To view permissions applied to the SharePoint Online list, follow these steps:

  1. Navigate to your SharePoint Online list >> Click on settings gear >> List settings.
  2. Click on the “Permissions on this List” link on the List settings page.
  3. This page gets you all permissions on the particular list.
    sharepoint online powershell get list permissions

However, exporting permissions from lists and libraries in the SharePoint Online user interface can be a complex and time-consuming process. So, let’s simplify this task by using PowerShell to get list permissions in SharePoint Online.

SharePoint Online PowerShell to Get List Permissions

Luckily, we have PowerShell to generate permission reports in SharePoint Online at various levels: Permission Reports in SharePoint Online using PowerShell, Here is the PowerShell to get list permissions and export to CSV in SharePoint Online:

#Load SharePoint CSOM Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\16\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
  
#Function to Get List Permissions
Function Get-SPOListPermission([String]$SiteURL, [String]$ListName)
{
    Try{
        #Setup the context
        $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteURL)
        $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
      
        #Get the List
        $List = $Ctx.Web.Lists.GetByTitle($ListName)
        $Ctx.Load($List)
        $Ctx.ExecuteQuery()
 
        #Get permissions assigned to the List
        $RoleAssignments = $List.RoleAssignments
        $Ctx.Load($RoleAssignments)
        $Ctx.ExecuteQuery()
 
        #Loop through each permission assigned and extract details
        $PermissionCollection = @()
        Foreach($RoleAssignment in $RoleAssignments)
        { 
            $Ctx.Load($RoleAssignment.Member)
            $Ctx.executeQuery()
 
            #Get the User Type
            $PermissionType = $RoleAssignment.Member.PrincipalType
 
            #Get the Permission Levels assigned
            $Ctx.Load($RoleAssignment.RoleDefinitionBindings)
            $Ctx.ExecuteQuery()
            $PermissionLevels = ($RoleAssignment.RoleDefinitionBindings | Select -ExpandProperty Name) -join ","
             
            #Get the User/Group Name
            $Name = $RoleAssignment.Member.Title # $RoleAssignment.Member.LoginName
 
            #Add the Data to Object
            $Permissions = New-Object PSObject
            $Permissions | Add-Member NoteProperty Name($Name)
            $Permissions | Add-Member NoteProperty Type($PermissionType)
            $Permissions | Add-Member NoteProperty PermissionLevels($PermissionLevels)
            $PermissionCollection += $Permissions
        }
        Return $PermissionCollection
    }
    Catch {
    write-host -f Red "Error Getting List Permissions!" $_.Exception.Message
    }
}
  
#Set Config Parameters
$SiteURL="https://crescent.sharepoint.com/sites/Marketing"
$ListName="Documents"
$ReportFile = "C:\Temp\ListPermissions.csv"
  
#Get Credentials to connect
$Cred= Get-Credential
  
#Call the function to Get List Permissions
$ListPermissions = Get-SPOListPermission $SiteURL $ListName

#Get List Permissions
$ListPermissions

#Export List Permissions to CSV File
$ListPermissions | Export-CSV $ReportFile -NoTypeInformation

And the exported CSV file looks like this:

sharepoint online powershell list permissions

In summary, using PowerShell to get list permissions in SharePoint Online can be a powerful tool for managing your SharePoint environment. By utilizing the script provided in this article, you can quickly and easily export the permissions from your SharePoint lists, helping you to maintain a secure and organized environment.

We can also export list or document library permissions to a CSV report with PnP PowerShell: Get SharePoint Online Document Library Permissions and Export to CSV using PnP PowerShell

Salaudeen Rajack

Salaudeen Rajack - Information Technology Expert with Two-decades of hands-on experience, specializing in SharePoint, PowerShell, Microsoft 365, and related products. He has held various positions including SharePoint Architect, Administrator, Developer and consultant, has helped many organizations to implement and optimize SharePoint solutions. Known for his deep technical expertise, He's passionate about sharing the knowledge and insights to help others, through the real-world articles!

3 thoughts on “SharePoint Online: PowerShell to Get List Permissions

Leave a Reply

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