Using the Exchange Management Shell, you can add all mail-enabled users to a Distribution Group by using the following command.
It will:
- Add all mail-enabled users to the ‘Human Resources’ distribution list
- Exclude all other mail object (Discovery Services, Booking Resources, Meeting Room Resources).
foreach($mbx in Get-Mailbox -Filter { RecipientTypeDetails -eq "UserMailbox"}){Get-Mailbox $mbx.identity | Add-DistributionGroupMember -Identity "Human Resources"}