Skip to content

Instantly share code, notes, and snippets.

@zaskem
Created April 15, 2020 22:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save zaskem/e182363868cd685547553cd8a2f5588c to your computer and use it in GitHub Desktop.
Save zaskem/e182363868cd685547553cd8a2f5588c to your computer and use it in GitHub Desktop.
$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