Powershell function to list AD groups with no members

3/14/2014 , 0 Comments


Below PowerShell function lists AD groups with no members in them.

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
        }
    }
}

0 comments :