I am working on the below script to get DL member count:
$DistributionGroups = Get-DistributionGroup -Resultsize Unlimited
$DistributionGroups |? {!((Get-DistributionGroupMember -resultsize unlimited $).count -gt 100)} | Select Name,PrimarySmtpaddress,@{n=“Count”;e={(Get-DistributionGroupMember -resultsize unlimited $).count}} | export-csv final.csv
The above script will give me DL Name and Count if it has more than 100 members in it.
However the problem is if DL has 50 members and a nested DL( with more than 100 members in it); then I wont be able to get the output.
I need to have an output that would give me DL Name and count of members (which includes the members of nested DL)
Thanks Olaf for taking some time out and checking on it.
I have tried get-adgroupmember in past but if the group has more than 1000 members then it won’t give an output. I have used dsget.exe commands to pull out group members details and query members.
In my case, I have DL’s with nested DL’s containing more than 1000 members.
Shashank, I wrote a function for my company a few months that returns the recursive members of a distribution group plus the name of the nest group they were in. Maybe it might help : Get-DistributionGroupMemberRecursive