← script library

Efficiently List User Permissions in SharePoint with PowerShell

SharePoint & OneDriveDecember 24, 2024

In this post, we will provide a PowerShell script that helps you list user permissions for a SharePoint site. Understanding who has access to what information is crucial for managing security and compliance levels in your organization. This script will retrieve and display a detailed list of users and their corresponding permissions on the specified SharePoint site, making it easier for administrators to ensure that access levels are appropriate. Here is the PowerShell script for listing SharePoint user permissions:

powershell
# Connect to SharePoint Online
$siteUrl = "https://yourtenant.sharepoint.com/sites/YourSite"
$credential = Get-Credential
Connect-PnPOnline -Url $siteUrl -Credentials $credential
# Get all users and their permissions for the site
$users = Get-PnPUser
# Create a report of user permissions
$permissionReport = foreach ($user in $users) {
    $permissions = Get-PnPUserEffectivePermissions -User $user.LoginName
    [PSCustomObject]@{
        User          = $user.LoginName
        Permissions   = ($permissions | ForEach-Object { $_.Name }) -join ', '
    }
}
# Output the permission report
$permissionReport | Format-Table -AutoSize
Write-Host "User permissions listed successfully for the site."

Run it across your fleet

This script runs as-is on a single host. Paste it into ServerEngine to schedule it, run it on a whole server group in parallel, and keep the credentials out of the file — see the scripts documentation and the credential store.

Ready when you are.

Try ServerEngine free for 7 days.