Task – Find Empty Distribution Groups In Exchange 2007…

All exchange admins working for bigger firms are familiar with large number of distribution groups present in the exchange environment. Sometimes different departments put the request for new distribution groups to be created, but will be used rarely or not at all. At times, the groups will be empty as well, either because the members have left the company or it was never populated.

How can we find out the distribution groups which doesn’t have any members in it? Powershell to the rescue. Run

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 1 }

In order to output the name and primarysmtpaddress of empty distribution groups in a nicely formatted table, run

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 1 } | ft name, primarysmtpaddress -wrap

As always, you can get the output in a txt,csv or html file.

Get-DistributionGroup | Where-Object { (Get-DistributionGroupMember –identity $_.Name).Count –lt 1 } | ft name, primarysmtpaddress –wrap | Out-File c:emptygroups.txt

10 thoughts on “Task – Find Empty Distribution Groups In Exchange 2007…”

  1. HI!

    I have a different problem connected to this groups: I would like to find all the distribution groups one user is a member of – how can I get a list of this groups?


  2. sorry. there's a missing set of parentheses in my previous post:

    ([array](Get-DistributionGroupMember –identity $_.Name)).Count

    The "." is more tightly bound than the typing.

  3. You should change the get-distributiongroupmember to use $_.distinguishedname.

    In most cases, the "Name" property will be unique, but there's no guaranty that it is always the case. If the "Name" property matches multiple groups there'll be an error thrown. Using the DN avoids that problem.

  4. The problem with groups having only a single member is that the cmdlet returns a scalar (which has no 'count').

    Coerce the result to be an array, even if it has just one member, and you should get the script to work correctly:

    [array](Get-DistributionGroupMember –identity $_.Name).Count

  5. Hi Anonymous,

    It shouldn't do that, as the cmdlet says to find groups with members less than 1. You can change it to "equal to zero" and try.


Leave a Comment