I have been asked to find all the SharePoint groups an specific o365 user is member of. I have searched for ways to do this and it looks like I have to use PowerShell and loop through all site collections and sites and foreach of them check if a user is added eg. a modified version of this script https://www.sharepointdiary.com/2019/09/sharepoint-online-user-permissions-audit-report-using-pnp-powershell.html

Another method to access the user in the admin center. It is true that there is a list of groups he is member of but that list is a mix of SharePoint Group, mailboxes, distribution list etc etc. and it looks impossible to determine if any of those are SharePoint groups.

Isn't there another way to accomplish this. We have thousands upon thousands of site collection and it will take for ever to look all of them.

1 Answer 1


You could export users and groups of all SharePoint Online site collections to CSV through PowerShell. Then filter data in the csv file.

#Admin Center & Site collection URL
$AdminCenterURL = "https://crescenttech-admin.sharepoint.com/"
$CSVPath = "C:\Temp\GroupsReport.csv"
#Connect to SharePoint Online
Connect-SPOService -url $AdminCenterURL -Credential (Get-Credential)
$GroupsData = @()
#Get all Site collections
Get-SPOSite -Limit ALL | ForEach-Object {
    Write-Host -f Yellow "Processing Site Collection:"$_.URL
    #get sharepoint online groups powershell
    $SiteGroups = Get-SPOSiteGroup -Site $_.URL
    Write-host "Total Number of Groups Found:"$SiteGroups.Count
    ForEach($Group in $SiteGroups)
        $GroupsData += New-Object PSObject -Property @{
            'Site URL' = $_.URL
            'Group Name' = $Group.Title
            'Permissions' = $Group.Roles -join ","
            'Users' =  $Group.Users -join ","
#Export the data to CSV
$GroupsData | Export-Csv $CSVPath -NoTypeInformation
Write-host -f Green "Groups Report Generated Successfully!"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.