Exchange 2010 find empty distribution groups

When we often create distribution groups, we forget about them.

Then we can have empty distribution groups in our Exchange Organization.

To find empty groups we can use Powershell.

First solution we can use EMS with below commands:

$DGs = Get-DistributionGroup -resultsize unlimited
$DGs | where-object {!(Get-DistributionGroupMember $_)}

As a result we receive list of empty distributions groups.

Second solution is to use PowerShell and Quest ActiveDirectory snapin like below:

Get-QADGroup -SizeLimit 0 -Empty $true -GroupType Distribution

Then we can get also empty distribution groups, but we can also modify this command to find security groups.



Exchange 2010 assign rights to send to restricted distribution groups

In Microsoft Exchange we can set distribution group as restricted.
Then this distribution group will only accept messages from specified users.

We can set this settings in distribution group properties in tab Mail Flow SettingsMessage Delivery Restrictions.

In section Accept messages from select Only senders in the following list and add all users who can send messages to this group.

Messages from other users will be rejected



If we have many of distribution groups with restrictions and we need to assign send rights to this groups then we have a problem.

Continue reading

Distribution List members report

When you want to have report of your distribution groups with information who belong to these groups you can create PowerShell script to write each group to separate file with all members.

First you need to decide if you wan to specify distribution groups (like in file) or you want to get all distribution groups.

To get groups from file use:

$DLs = get-content d:\scripts\DLgroups.txt

to get all distribution groups use:

$DLs = get-distributiongroup -resultsize unlimited | select name
foreach ($dl in $DLs){
 if (!(get-distributiongroup $dl)){
 Write-Host "$dl is not valid"
 } else {
 $dl_tmp = get-distributiongroup $dl
 $outfile = "d:\scripts\DL_$($"
 Add-Content $outfile get-Date
 Add-Content $outfile "$($ $($dl_tmp.SMTPAddress)" 
 Add-Content $outfile "Members"
 Add-Content $outfile "Alias;Displayname;Company;Title;emailaddress"
 $members = get-distributiongroupmember $($dl_tmp.alias)

 foreach ($member in $members){
 $user = $member.alias + ";" + $member.DisplayName + ";" + $member.Company + ";" + $member.Title + ";" + $member.primarysmtpaddress.local + "@" + $member.Primarysmtpaddress.domain 
 Add-Content $outfile $user

With this short script you will get one file for each distribution group with members of this group.



Exchange 2010 hide distribution list members

In Microsoft Exchange 2003, hiding the membership of a distribution list was very easy, just right click Exchange Tasks>Hide Membership in the Exchange System Management console

Unfortunately this feature is not available in Exchange 2010.

To hide members of distribution group you can use dynamic distribution group, which enumerate the group membership based on an LDAP query for a particular attribute being set on the user object.

But if you don’t want to use dynamic distribution group or members of this group can’t be connected by any attribute, then you can modify distribution group object using ADSIEDIT to modify hideDLMembership attribute.

Open ADSIEDIT console, find distribution group, open properties and find hideDLMembership then set value of this attribute to True.




This modification will prevent the expansion of groups in Outlook and OWA





Get distribution group all members – nested

How can we get a list of mailboxes belonging to a distribution group?
In a simple way, by using the EMC console and check who is a member of a group, or by using powershell EMS console and use the command:

Get-DistributionGroupMember Test_Group


In this way we get a list of objects in the group, both mailboxes, contacts, and other groups.

And here there is a problem, because if the distribution group includes the next distribution group, and this again next etc, how can we get a list of all people who receive an email after sending a message to a distribution group?

Unfortunately, using only the Get-DistributionGroupMember we won’t get such information.

This command returns only the objects directly in a group, without nesting.

In this case, we have to use PowerShell commands for Active Directory available.

To do this run EMS console and import the Active Directory module command as follows:

import-module ActiveDirectory

Continue reading

Exchange 2010 remove disabled users from distribution group

To keep Exchange Distribution Groups in order, we recommend to “clean” members of those groups.

We should remove all disabled users from distribution groups.

When we have a lot of Distribution Group we can use powershell script like below to do this.

This script gets all Distribution Groups from Exchange Organization, then will check every group for users which are disabled and they have Active Directory account in specified OU.

This script will also export all informations to a .csv file, where you can find following informations:


  • Name of distribution group
  • user DisplayName
  • SamAccountName
  • path in Active Directory to user account

Continue reading

Exchange 2010 find empy distribution groups

When you have big Microsoft Exchange environment, you probably have many Distribution Groups.

Often you create distribution groups when you need them or someone need, and after that you forget about them.

It’s good to clean unused grups from time to time.

Below we present powershell command to find distribution groups without members.

If you have any distribution group without members, you will receive informations about name, smtp address and Managed By.

You can simply use below commands:

$DistrGroups = Get-DistributionGroup -ResultSize Unlimited
ForEach ($DistrGroup in $DistrGroups) { 
 if (!$(Get-DistributionGroupMember -Identity $DistrGroup.’DistinguishedName’)) { 
  Write-Host $DistrGroup.DisplayName "," $DistrGroup.PrimarySmtpAddress "," $DistrGroup.ManagedBy



Search-Mailbox delete emails sent to Distribution Group


When someone will send email to wrong distribution group you can easly delete this email using Search-Mailbox CMDlet.

All you need it’s to get distribution group members and run for each of them search-mailbox.

Below you can find example how to remove email sent to distribution group Important_DL     with subject Confidential Report.

Get-DistributiongroupMember Important_DL | Search-Mailbox -SearchQuery subject:"Confidential Report" -DeleteContent -Force:$TRUE


Above command will delete email with subject Confidential Report from users mailboxes which are members of Important_DL distribution group.

You can also use others attribute to define email properties to delete.

Below you can find more properties which you can use:

Continue reading