0

Is it possible to list all groups on the SPO website along with the users who belong to a given group and export the results to Excel?

I would like to add that 2FA is enabled on the website.

Unless there is an easier way than PowerShell.

I want to have a permissions matrix for a given site.

1

1 Answer 1

0

Please try this powershell:

#Admin Center & Site collection URL
$AdminCenterURL = "https://Crescent-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!"

Reference: SharePoint Online: Site Users and Groups Report using PowerShell

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.