I have seen many threads on exporting groups and getting members, but strangely not both. Basically I need a .csv file or similar with every AD group and its corresponding members.
I believe it needs to be done from Azure as we have multiple domains and Office 365/incloud groups (Azure AD has all of these listed).
So I don't think there is another way to export our groups to a single CSV file.
This PowerShell script should return you what you are looking for in CSV format (one line for each group/member value).
$groups=Get-AzureADGroup -All $true
ForEach ($group in $groups){
$members = Get-AzureADGroupMember -ObjectId $group.ObjectId -All $true
ForEach ($member in $members){
Write-output $group.DisplayName "," $member.ObjectId "," $member.ObjectType $member.UserType "," $member.UserPrincipalName >> C:\scripts\output.csv
}
}