Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

We had a distribution group on Exchange 2010 which didn't had any members for long time (nobody noticed). What happens to the emails that come to such group? There was no return messages or anything.

share|improve this question

4 Answers 4

up vote 5 down vote accepted

Unfortunately all those emails have gone into the black hole. Exchange has done it's job, it looked up recipients but nothing exist, therefore discards the email. You would need an archive/compliance setup to retrieve those emails.

Also note: You would not receive any NDRs either, the process did completed as expected.

share|improve this answer
    
As I expected but wanted to confirm. Thanks –  MadBoy Feb 16 '12 at 11:14

They go nowhere unfortunately. We've set up a PowerShell script that runs daily and will email us if it finds empty distribution groups.

Just put this in a .ps1 file and schedule it to run at whatever interval you prefer.

$FromAddress = "exchserver@example.com"
$ToAddress = "itdept@example.com"
$MessageSubject = "Empty distribution groups"
$SendingServer = "exchserver.example.com"

$groups = Get-DistributionGroup
$emptygroups = ($groups | ? { !(Get-DistributionGroupMember $_) })

if ($emptygroups.count -gt 0) {
    $MessageBody = "The following Exchange distribution groups have no members:`r`n`r`n"
    $MessageBody += ($emptygroups | Select-Object DisplayName | Out-String)

    $SMTPMessage = New-Object System.Net.Mail.MailMessage $FromAddress, $ToAddress, $MessageSubject, $MessageBody

    $SMTPClient = New-Object System.Net.Mail.SMTPClient $SendingServer
    $SMTPClient.Send($SMTPMessage)
}
share|improve this answer
    
Thanks. Nice script. Definitely gonna set it up. –  MadBoy Feb 16 '12 at 11:44

Here's an update on possible code. A more efficient query since it only returns a list of empty groups. A bit obtuse since one is led to think Get-DistributionGroup doesn't know about members (thus the need for the Get-DistributionGroupMember cmdlet).

$emptygroups = Get-DistributionGroup -Filter {members -eq $null}

I've confirmed that works on Exchange 2010, SP2, RU5v2.

share|improve this answer
    
Thanks I'll verify –  MadBoy Jul 14 '13 at 10:43

Thanks! For me the nothing was happening with the above script - not sure if it's a different Powershell version or such like (Exchange 2010, Server 2008 R2) but there was nothing in the "count" attribute.

I had to replace:

if ($emptygroups.count -gt 0) {

With:

$emptygroupcount = echo $emptygroups | measure
if ($emptygroupcount.Count -gt 0) {

If anyone is wondering how to do a schedule of this, since the "basic" Powershell doesn't recognise the Exchange commands, I created a wrapper batch file as per http://social.technet.microsoft.com/Forums/exchange/en-US/0cad57bf-1113-4622-aac3-c3278fa97d72/how-to-schedule-a-powershell-script-through-schedule-tasks?forum=exchange2010

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.