This is one of the most common requirement which you get from the site owners, they want to know who have access to the site. This is also one of the important report which one need at the time of site migration. You can generate this report with help of the migration tools. Or can go to the site permissions to verify who have access on the site by looking to site permissions.

For viewing site permissions, go to site settings and click on site permissions. Or use below URL to directly access the site permissions.

https://<tenant name>.sharepoint.com/_layouts/15/user.aspx

You can see the site security groups, click on check permissions to verify permissions for any of the user.

Generate Site permission report using Power Shell

I am sharing a PowerShell script which you can run using Site collection admin account and generate the site permission report.

$siteURL = "https://mstechtalkdemodev.sharepoint.com/"
 
#Connect to Site
Connect-PnPonline -Url $siteURL -Interactive
 
#Get the web
$web = Get-PnPWeb -Includes RoleAssignments
 
#Loop through each permission assigned and extract details
$permissionData = @()
ForEach ($roleAssignment in $web.RoleAssignments)
{
    #Get the Permission Levels assigned and Member
    Get-PnPProperty -ClientObject $roleAssignment -Property RoleDefinitionBindings, Member
     
    #Get the Permission Levels assigned
    $permissionLevels = ($roleAssignment.RoleDefinitionBindings | Select -ExpandProperty Name | Where { $_ -ne "Limited Access"} ) -join ","
     
    #Leave Principals with no Permissions
    If($permissionLevels.Length -eq 0) {Continue}
 
    $permissionType = $roleAssignment.Member.PrincipalType
    #Get SharePoint group members
    If($permissionType -eq "SharePointGroup")
    {
        #Get Group Members
        $groupMembers = Get-PnPGroupMember -Identity $roleAssignment.Member.LoginName
                   
        #Leave Empty Groups
        If($groupMembers.count -eq 0){ Continue }
        $groupUsers = ($groupMembers | Select -ExpandProperty LoginName | Where { $_ -ne "SHAREPOINT\system"}) -join "; "
   
        #Add the Data to Object
        $permissions = New-Object PSObject
        $permissions | Add-Member NoteProperty Name($roleAssignment.Member.Title)
        $permissions | Add-Member NoteProperty Accounts($groupUsers)
        $permissions | Add-Member NoteProperty Type($permissionType)
        $permissions | Add-Member NoteProperty PermissionLevels($permissionLevels)
        $permissionData += $permissions
    }
    Else
    {
        #Add the Data to Object
        $permissions = New-Object PSObject
        $permissions | Add-Member NoteProperty Name($roleAssignment.Member.Title)
        $permissions | Add-Member NoteProperty Accounts($roleAssignment.Member.LoginName)
        $permissions | Add-Member NoteProperty Type($permissionType)
        $permissions | Add-Member NoteProperty PermissionLevels($permissionLevels)
        $permissionData += $permissions
    }
} 
#Export Permissions data to CSV file
$permissionData | Out-GridView

Adnan is six time Microsoft MVP (Since 2015) with over 16 years of extensive experience with major expertise on SharePoint, SharePoint based development, Microsoft 365, Microsoft Teams, .Net Platform and Microsoft BI. He is currently working Sr Microsoft Consultant at Olive + Goose. He is MCT Regional Lead for Pakistan Chapter since 2012. He is working on SharePoint for past 12 years and worked on different intranet/intranet solutions for private & govt. sector majorly in United states and Gulf region and have experience of working with multiple Fortune 500 companies. He is a trainer, technology evangelist and also speaks in community forums.

Leave a Reply