Groups with no members in them are, in my opinion, a waste of a perfectly good object 😉
So here is a function to find groups that have no users and no groups as member…
1 2 3 4 5 6 7 8 9 |
function Get-EmptyGroups { $Groups = Get-ADGroup -Filter * -Properties members foreach ($Group in $Groups) { $GroupMembers = $Group | Select-Object -ExpandProperty members if ($groupmembers -eq $null) { $Group.Name } } } |