@Dhamley
Note: The account to be used in the PowerShell should be the administrator of all these site collections.
1.Create a csv file as following picture shows.
2.Please run below PowerShell to get all members of all groups in the given site collections of csv file.
$Credentials=Get-Credential
$InputCSVPath = "C:\Temp\sitecollections.csv"
$OutputCSVPath = "C:\Temp\GroupsReport.csv"
$csv = Import-Csv $InputCSVPath
$a = $csv.Url
$GroupsData = @()
ForEach($_ in $a) {
Connect-SPOService -url $_ -Credential $Credentials
Get-SPOSiteGroup -Site $_
$SiteGroups = Get-SPOSiteGroup -Site $_
ForEach($Group in $SiteGroups)
{
$GroupsData += New-Object PSObject -Property @{
'Site URL' = $_.URL
'Group Name' = $Group.Title
'Permissions' = $Group.Roles -join ","
'Users' = $Group.Users -join ","
}
}
}
$GroupsData | Export-Csv $OutputCSVPath -NoTypeInformation
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.