Script – Find Empty Distribution Groups in Exchange 2010

During or after migration activities, a lot of distribution groups become unused since they do not contain any members in it. Administrators working for large organizations must have gone through such requirement several times.

I was asked to find such distribution groups at one of our customers. Only a few lines of code can do this listing for you. Codes available on internet right now use pipelining and fail to give desired results if you are using remoting. So, here is that small piece of code:

$dls = Get-DistributionGroup -ResultSize Unlimited

Foreach ($dl in $dls) { if ((Get-DistributionGroupMember -Identity $dl.’DistinguishedName’).Count -lt 1) { Write-Host $dl.DisplayName "," $dl.PrimarySmtpAddress}}

5 thoughts on “Script – Find Empty Distribution Groups in Exchange 2010”

  1. Hi
    your script will also return Distribution Groups with 1 member.
    You should use something like that
    $dls = Get-DistributionGroup -ResultSize Unlimited
    Foreach ($dl in $dls) {
    if (!(Get-DistributionGroupMember -Identity $dl.’DistinguishedName’)) { Write-Host $dl.DisplayName “,” $dl.PrimarySmtpAddress}}

  2. Neither one of these work for me. They just keep returning all 2010 Disto’s. I have a few that don’t have members, but they aren’t the only ones returned.

Comments are closed.