I decided to use PowerShell for that. I have never used PS cmdlets for SharePoint Online before, so this is my first try. I hope it is useful for you.
$cred = Get-Credential
$adminSite = "https://contoso-admin.sharepoint.com/"
$rootSite = "https://contoso.sharepoint.com/"
Connect-SPOService -Url $adminSite -Credential $cred
$groups = Get-SPOSiteGroup -Site $rootSite
$objectCollection = $groups |
ForEach-Object {
$groupName = $_.LoginName
$_.Users | ForEach-Object {
$user = Get-SPOUser -Site $rootSite -LoginName $_
$properties = @{
GroupName = $groupName;
UserName = $user.DisplayName;
LoginName = $_
}
New-Object -TypeName PSObject -Property $properties
}
}
Disconnect-SPOService
$objectCollection
Let me know in the comments if there is something that can be done to make it run faster (it takes about 80 second to complete for this specific tenant).