Reporting on distribution group membership

One of the common requests you are likely to receive as an Exchange administrator is to generate a report detailing which recipients are members of one or more distribution groups. In this recipe, we'll take a look at how to retrieve this information from the Exchange Management Shell.

How to do it...

To view a list of each distribution group member interactively, use the following code:

foreach($i in Get-DistributionGroup -ResultSize Unlimited) {
  Get-DistributionGroupMember $i -ResultSize Unlimited | 
    Select-Object @{n="Member";e={$_.Name}},
      RecipientType,
      @{n="Group";e={$i.Name}}
}

This will generate a list of Exchange recipients and their associated distribution group membership.

How it works...

This code ...

Get Microsoft Exchange 2010 PowerShell Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.