Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
$groups = Get-ADGroup -Filter 'Name -like "PATTERNGOESHERE*"' | Select-Object Name, SamAccountName;
"There are "+ $groups.Count +" matching groups.";
$groupDetails = ForEach ($grp in $groups) {
New-Object PSObject -Property @{'Group Name'=$grp.Name;Count=(Get-ADGroupMember $grp.SamAccountName -Recursive).Count};
}
$groupDetails | Sort-Object -Property Count -Descending | Select-Object 'Group Name', Count;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.