Found on this link:
https://ourcloudnetwork.com/export-all-microsoft-365-groups-and-members-with-powershell/
Power Shell as Administrator:
Connect to Tennent:
Connect-ExchangeOnline
Use the following script to export a list of all Microsoft 365 groups and their members to a All-M365-Group-Members.csv file.
$Result=@()
$groups = Get-UnifiedGroup -ResultSize Unlimited
$totalmbx = $groups.Count
$i = 1
$groups | ForEach-Object {
Write-Progress -activity “Processing $_.DisplayName” -status “$i out of $totalmbx completed”
$group = $_
Get-UnifiedGroupLinks -Identity $group.id -LinkType Member | ForEach-Object {
$member = $_
$Result += New-Object PSObject -property @{
GroupName = $group.DisplayName
Member = $member.Name
EmailAddress = $member.PrimarySMTPAddress
RecipientType= $member.RecipientType
}}
$i++
}
$Result | Export-CSV “All-M365-Group-Members.csv” -NoTypeInformation -Encoding UTF8
Kon Belieu
Comments are closed