Wednesday, October 23, 2019

Get Group Members of multiple exchange distribution groups using PowerShell

Get Group Members of multiple exchange distribution groups using PowerShell

Create a text file  'C:\temp\AllGroups.txt' and put all group names.

$allgroup = Get-Content C:\temp\AllGroups.txt

foreach($i in $allgroup) {Get-DistributionGroupMember -Identity $i -ResultSize unlimited | Select-Object  @{n='Groupname';e={$i}}, DisplayName,Alias,DistinguishedName,SAMAccountName,Id,PrimarySmtpAddress,RecipientType,ExternalEmailAddress | Export-Csv c:\temp\GroupWithMembers.csv -Append -NoTypeInformation }