Share via


Office 365 - List "Displayname" and email address of members of a distribution group.

Question

Wednesday, February 15, 2017 3:50 PM

HI, 

Would someone advise a PS command to list display name and smtp address of group members in Office 365?

The group is a distribution group.  

Thanks.

All replies (7)

Wednesday, February 15, 2017 4:06 PM

Hi EdKc,

You can refer below artcile:-

- https://gallery.technet.microsoft.com/Export-all-distribution-707c27eb


Wednesday, February 15, 2017 4:50 PM

Thanks, Ed. 

How do I use the PS1 on a particular distribution group instead of all the groups?  Would you give me an example?

I tried the native tool myself but I do not know how to display the email addresses.  This command works but it just displays the displayname:

get-distributiongroupmember -identity "mydistributiongroup" | fl displayname


Thursday, February 16, 2017 10:42 AM

Hi Ed,

get-distributiongroupmember -identity "mydistributiongroup" | fl displayname --> This command wil not give you the primary smtp address

You can do below

 Once you get the displayname of the users by running above command > You can then export it to a .TXT file or a .CSV file for eg:-

get-distributiongroupmember -identity "mydistributiongroup" | select displayname > Txt.txt

Get-content c:\folder\txt.txt | get-mailbox | select displayname, primarysmtpaddress


Thursday, February 16, 2017 2:37 PM | 1 vote

Hello,

For a special distribution group, you can run below command to list the DisplayName, PrimarySmtpAddress for each members:
$Members = (Get-DistributionGroupMember DGName).Identity
Foreach ($member in $members) { Get-Mailbox $Member | select DisplayName,PrimarySMTPAddress}

Figure as below:

Best Regards,

Allen Wang

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


Monday, February 20, 2017 2:42 AM

Any updates about this issue? If anything unclear about above command, feel free to let me know.

Best Regards,

Allen Wang

Please remember to mark the replies as answers if they help.
If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.


Wednesday, March 1, 2017 6:19 AM

I have a script in the gallery that can be used to import/export groups, members, and the DL proxy addresses.

https://gallery.technet.microsoft.com/Distribution-Group-Report-d32c4788


Friday, May 24, 2019 6:49 AM | 2 votes

If the group member has a mailbox, then the member will have a primary SMTP address. If the group member is User or Contact, it won't have Primary SMTP Address. 

Get-DistributionGroupMember -Identity <GroupName> | 
               Select-Object Name,PrimarySmtpAddress,@{Label = 'Group'; Expression = { $Group } }

If you want to export distribution group with more attributes like Group Owner, Members count, Member recipient type, etc, you can try below script.

Export Office 365 Distribution Group Members to CSV

Script Highlights:

  • You can choose to either “Export Members of all Distribution Lists” or pass an input file to “Export Members of Specific Distribution List”.
  • Allows you to filter the report result based on group size(i.e., Members count).
  • Output can be filtered to list Empty group. i.e., Distribution Group without members
  • The script can be executed with MFA enabled account.
  • You can filter the output based on whether the group accepts message from external senders or not.
  • Exports the report result to CSV.
  • Above all, script exports output in nicely formatted 2 CSV files. One with detailed information and another with summary information.