Forum Discussion
sparkislife
Apr 21, 2022Copper Contributor
List off all AD groups that have between 1 and 3 users
I am looking for help with listing off all AD Groups that have between 1 and 3 members.
sparkislife
Apr 25, 2022Copper Contributor
Looking at explicit and am looking for user count per group.
LainRobertson
Apr 25, 2022Silver Contributor
sparkislife wrote:
Looking at explicit and am looking for user count per group.
Okay, in this case, something like this will suffice. You can add and remove any attributes you'd like.
Get-ADObject -Filter { (objectClass -eq "group") -and (member -like "*") } -Properties member | Select-Object -Property objectGUID, name, @{n="count"; e={ $_.member.Count; }} | Where-Object { $_.Count -in 1 .. 3 }
Cheers,
Lain
- sparkislifeApr 28, 2022Copper Contributor
worked fine thx.