Exchange Server 2007 – Removing Messages from the Queue

After a slow day yesterday, I came into work this morning to find that our exchange server had a small problem. What I was faced with was one of our monitoring systems had lost a bit of control and was mass mailing server email accounts on the network. Becuase of this no one was geting mail as the queue was so large and was just trying to clean up. After a bit of searching I found some easy powershell scripts that saved us.

The first was a simple one liner that showed us how big the actual queue was.

Get-Queue -Server “<ServerName>”

The next simple script was used to remove the ofending messages from the queue.

remove-message -server “<ServerName>” -filter {FromAddress -like ““} -withNDR $false

What we did find was that if you left off the -withNDR statement it would default to true and send another email with the NDR, thus increasing our problem. To monitor the queue and the progress of the script I did have to open another Exchange Management Console an run the Get-Queue command.

Off course in the above scripts I have removed the server name and email adress that was our actual problem, but the above scripts could also be used to wipe out a virus email that hits your Exchange 2007 System.

Cross Post from

4 thoughts on “Exchange Server 2007 – Removing Messages from the Queue”

  1. Thank you for this, so many people posted that it was impossible and you could only stop the service and rename the queue database, losing all of the e-mail in the queue.

Leave a Reply

Your email address will not be published. Required fields are marked *