Get-DistributionGroupMember

Roger Roger 5,066 Reputation points
2023-06-19T05:10:40.1666667+00:00

Hi All

i have mail enabled security group in exchange online. i want to export the mail enabled security group members to csv file. will the below syntax work.

Get-DistributionGroupMember -Resultsize Unlimited mailenabledsecuritygroup@contoso.com | Select DisplayName,title,userprincipalname,PrimarySMTPAddress,RecipientType |  Export-csv -path C:\temp\output.csv -NoTypeInformation

Microsoft Exchange Online
Microsoft Exchange Online Management
Microsoft Exchange Online Management
Microsoft Exchange Online: A Microsoft email and calendaring hosted service.Management: The act or process of organizing, handling, directing or controlling something.
4,348 questions
Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,467 questions
Microsoft Exchange Hybrid Management
Microsoft Exchange Hybrid Management
Microsoft Exchange: Microsoft messaging and collaboration software.Hybrid Management: Organizing, handling, directing or controlling hybrid deployments.
1,979 questions
{count} votes

Accepted answer
  1. Yuki Sun-MSFT 40,931 Reputation points
    2023-06-20T03:10:06.3933333+00:00

    Hi @Roger Roger ,

    UserPrincipalName will be empty in the command you shared above. Based on my test, you can use the command below so that all properties listed can be included:

    Get-DistributionGroupMember -Resultsize Unlimited mailenabledsecuritygroup@contoso.com | %{Get-Mailbox $_.Name | select DisplayName,userprincipalname,@{Expression={(Get-User $_.Name).title};Label="title";},PrimarySMTPAddress,RecipientType} |  Export-csv -path C:\temp\output.csv -NoTypeInformation
    
    

    User's image



    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.

    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Vasil Michev 99,431 Reputation points MVP
    2023-06-19T15:50:27.1233333+00:00

    it will work, however not all selected properties will be exposed, as the output of the cmdlet returns a ReducedRecipient object. For example, Title and UserPrincipalName will be empty. If you need to include these properties, you will have to make additional calls to the Get-User cmdlet or similar.

    0 comments No comments