Who Has Access? PowerShell to List Every User with Access to a SharePoint Site, Library or File
To list who can access a SharePoint site, read the site's role assignments, expand each SharePoint group to its members, expand Microsoft 365 and security groups, and add the site collection admins. For a file, do the same on the file if it has unique permissions, otherwise on the nearest parent that does, and include sharing links. Get-PnPUser alone lists everyone who ever visited, not who has access. The free SharePoint Essentials Toolkit does all of this across sites without code.
Published:
Last updated: 2026-10-29
Why the obvious commands give the wrong answer
Get-PnPUser/Get-SPOUserlist the site's User Information List: everyone who has ever been added or visited, including people whose access was removed. It's not who has access.- Group membership isn't permission. A SharePoint group only grants access through a role assignment. Members of a group with no role on the site have nothing.
- Groups nest. A SharePoint group can contain a Microsoft 365 group or a security group, which contains people. "Everyone except external users" is one entry but means the whole organization.
- Unique permissions. Libraries, folders and files can break inheritance. The site's permissions say nothing about them.
- Sharing links grant access through hidden "SharingLinks" groups, and leave "Limited Access" entries up the hierarchy.
- Site collection admins have full control without any role assignment.
Option 1: Check in the browser
- A site: Settings, Site permissions, then Advanced permissions settings for the role assignments. Click a group to see its members. Site collection admins are under the ribbon's Site Collection Administrators.
- A file: select it, Manage access. It shows the people, groups and sharing links, but not which group members are behind "Members" or an Entra ID group.
- Check Permissions on the Advanced permissions page answers "what can this one person do here", including through groups.
Fine for one site or file. For anything bigger, use a script or a report.
Option 2, script 1: Everyone with access to a site
This read-only PnP PowerShell script lists the site's role assignments, expands SharePoint groups and Entra ID groups to people, and adds the site collection admins. It needs PnP PowerShell 3.x and your own Entra ID app registration with Group.Read.All to expand Entra groups.
$ClientId = "<your-app-id>"
$SiteUrl = "https://contoso.sharepoint.com/sites/Projects"
Connect-PnPOnline -Url $SiteUrl -Interactive -ClientId $ClientId
function Expand-Principal($p, $via) {
# Entra ID / Microsoft 365 group: "c:0t.c|tenant|<id>" (security) or "c:0o.c|federateddirectoryclaimprovider|<id>" (M365)
if ($p.PrincipalType -eq "SecurityGroup" -and $p.LoginName -match '\|([0-9a-f-]{36})(_o)?