Exchange 2013- Need count of DL members alongwith members of nested DL's

Hi,

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)

Could you please format your code as code here in the forum?

This Technet Forum thread might be helpful for you:

Get-DistributionGroupMember Recursive Functionality.

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.

You could try using Get-ADObject. If I remember right there not such a limit.

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