Forum Discussion
List off all AD groups that have between 1 and 3 users
It'd be useful to know from the poster if this is explicit or transitive, and related to members that are users or of any object type.
I couldn't motivate myself to ask but they're all things that would definitely impact the script.
Here's a quick one-liner that demonstrates pulling the transitive membership, which requires an additional round trip per group (since it's only available on base searches) and the explicit requesting of the msds-memberTransitive constructed attribute (i.e. using "-Properties *" doesn't cut it.)
(Get-ADGroup -SearchBase ((Get-ADGroup -Identity "Domain Admins").distinguishedName) -SearchScope Base -Filter * -Properties msds-memberTransitive).'msds-memberTransitive'.Count
Anyhow, that's all from me as the question's too open to know how best to answer at the moment.
Cheers,
Lain
LainRobertson It was the most simple one to get a list of groups which match the 1-3 member requirement. But the get-adgroupmember also has a -recursive parameter which lists all nested membership too.