You could execute the following script:
The first script: List the specific Distribution Group Members.
#Connect to Exchange Online Remote PowerShell.
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName "user@test.com" -ShowProgress $true
#List all the Microsoft 365 groups in Microsoft 365.
Get-UnifiedGroup -ResultSize Unlimited
#list all members of a selected single Microsoft 365 group
Get-UnifiedGroupLinks –Identity test –LinkType Members –ResultSize Unlimited
The second script: Get all the information related to every Microsoft 365 Group member, and export to CSV file.
#Connect to Exchange Online Remote PowerShell.
Import-Module ExchangeOnlineManagement
Connect-ExchangeOnline -UserPrincipalName "user@test.com" -ShowProgress $true
#--------------------------#
$Groups = Get-UnifiedGroup -ResultSize Unlimited
$Groups | ForEach-Object {
$group = $_
Get-UnifiedGroupLinks -Identity $group.Name -LinkType Members -ResultSize Unlimited | ForEach-Object {
New-Object -TypeName PSObject -Property @{
Group = $group.DisplayName
Member = $_.Name
EmailAddress = $_.PrimarySMTPAddress
RecipientType= $_.RecipientType
}}}} | Export-CSV "C:\\Office365GroupMembers.csv"
Thanks,
Echo Du
================
If an Answer is helpful, please click "Accept Answer" and upvote it.
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.