Hello, I’m trying to script a count of all members for each distribution group. This task is for troubleshooting purposes in which our AD azure sync isn’t syncing all members of our AD distro groups to Office 365 - members are missing in Exchange online.
So, for now, I like to script a way to give me the count of all members for each distribution group.
This works fine but its only one group at a time:
$GN = read-host “Enter distro group name”
$Count = (Get-DistributionGroupMember -Identity $GN | select name).count
Write-host -ForegroundColor Cyan $GN has $Count members
I tried running this but it failed:
$GN = gc d:\distros.txt
foreach($name in $GN) {
$Count = (Get-DistributionGroupMember -Identity $name | select name).count
Write-host -ForegroundColor Cyan $GN has $Count members
}
I’ll appreciate the help in showing me where I’m going wrong with enumerating all distribution groups via a text file of all distribution group names.
I’m looking for an output on console or export to file that gives this information:
Group A has 5 members
Group B has 7 members
Group C has 10 members
etc…
Thank you!