Live training: next batches coming soon. Join the waitlist:Waitlists open:Developer Training →Developer →Copilot Studio Training →Copilot Studio →

How to Get SharePoint Site Members Using PowerShell (PnP and SPO)

A manager asks who can open the SPGuides site, and the Site permissions panel shows three group names instead of people. Click into Members and you find a Microsoft 365 group, not a list of names.

In this tutorial, we’ll build the get SharePoint site members PowerShell scripts our team runs before a permissions review. Every PnP command below ran read-only on our SPGuides site; real names are covered in the screenshots.

Quick answer: Connect with Connect-PnPOnline, then run Get-PnPGroupMember -Group (Get-PnPGroup -AssociatedMemberGroup), or the Owner/Visitor switches. On a group-connected site those groups only hold the Microsoft 365 group, so run Get-PnPMicrosoft365GroupMember for the people. Get-PnPUser lists the User Information List, including people who lost access.

What You Need Before You Start

  • PnP PowerShell 3.x in PowerShell 7.4 or later; see our guide to install PnP PowerShell.
  • Your own Entra ID app registration, because Connect-PnPOnline now needs a -ClientId. Give it Graph Group.Read.All for the Microsoft 365 group cmdlets.
  • Site owner or site collection admin rights on the site.
Connect-PnPOnline -Url "https://spguides.sharepoint.com/sites/SPGuides" `
    -ClientId "00000000-0000-0000-0000-000000000000" -Interactive   # your Entra ID app's client ID

Step 1: List the SharePoint Groups on the Site

Get-PnPGroup lists the groups. We hide the system SharingLinks and Limited Access groups, then use the three switches that return the default groups the SharePoint site owner sees under Site permissions.

Get-PnPGroup |
    Where-Object { $_.Title -notlike "SharingLinks*" -and $_.Title -notlike "Limited Access*" } |
    Select-Object Id, Title, OwnerTitle | Format-Table -AutoSize

"Owners group:   " + (Get-PnPGroup -AssociatedOwnerGroup).Title
"Members group:  " + (Get-PnPGroup -AssociatedMemberGroup).Title
"Visitors group: " + (Get-PnPGroup -AssociatedVisitorGroup).Title
Get-PnPGroup listing SharePoint site groups and the associated owners, members and visitors groups

Our site returned 11 groups, 7 after the filter.

Step 2: Get Owners, Members and Visitors with Get-PnPGroupMember

$groups = [ordered]@{
    Owners   = Get-PnPGroup -AssociatedOwnerGroup
    Members  = Get-PnPGroup -AssociatedMemberGroup
    Visitors = Get-PnPGroup -AssociatedVisitorGroup
}
foreach ($role in $groups.Keys) {
    "--- $role ($($groups[$role].Title))"
    $people = Get-PnPGroupMember -Group $groups[$role]
    if (-not $people) { "    (no members)"; continue }
    $people | Select-Object Title, PrincipalType, LoginName | Format-Table -AutoSize | Out-String -Width 130
}
Get-PnPGroupMember output for the SharePoint Owners, Members and Visitors groups of a group-connected site

On our group-connected site, Members held one SecurityGroup entry whose login starts with c:0o.c|federateddirectoryclaimprovider| plus the Microsoft 365 group ID. Owners held the same claim with an _o suffix, plus System Account, and Visitors was empty. To check one person, add -User "emily.carter@spguides.onmicrosoft.com".

Step 3: Expand Microsoft 365 Group Members

On a group-connected site, the group’s owners are site owners and its members are site members. For more ways to read them, see how to get Microsoft 365 group members using PowerShell.

$site = Get-PnPSite -Includes GroupId
"Microsoft 365 group ID: $($site.GroupId)"

Get-PnPMicrosoft365GroupOwner -Identity $site.GroupId |
    Select-Object DisplayName, UserPrincipalName | Format-Table -AutoSize
Get-PnPMicrosoft365GroupMember -Identity $site.GroupId |
    Select-Object DisplayName, UserPrincipalName, UserType | Format-Table -AutoSize