We all know that getting the members of nested distribution groups in Exchange can be cumbersome. Especially when those nested distribution groups have nested distribution groups and so on. I ran into this issue recently and have thrown together a quick PowerShell function that you can utilize to gather all user mailboxes.
How to Use
- Copy the PowerShell function into a PowerShell Window
- Run the following command: Get-DistributionGroupMembersRecursive -PrimarySmtpAddress email@example.com
In this demo, I queried my main Distribution Group, dl-parent. This is how the distribution groups are setup:
You can pipe this command to Export-CSV if you wish to get all of the mailbox properties of the members.