Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I needed to clear a bunch of messages out of the mail queue this morning, and thought it would be super nice to be able to query the queue(s) using Powershell. Any scripts out there?

Note: this is for SBS 2003, so no Exchange 2007 - but as an upgrade is near, a 2007-only answer will be just fine...

share|improve this question
up vote 2 down vote accepted

I don't know of a PowerShell script that will do it for Exchange 2003 (there may be one, just can't find it), with Exchange 2007 its very easy.

There is a script here that will clear the entire queue for you, using vbscript. Are you looking to do that, or to remove particular emails?

share|improve this answer
Get-ExchangeServer | ?{$_.IsHubTransportServer -eq $true} | Get-Queue | get-message | Remove-Message -withNDR $false
share|improve this answer
This will only work on Exchange 2007, not 2003 – Sam May 1 '09 at 23:21
" as an upgrade is near, a 2007-only answer will be just fine..." – slipsec May 2 '09 at 13:52

For Exchange 2003 I would use the Aqadmcli.exe from Microsoft PSS, the following link has a good overview of how to use it to bulk clear queues.

share|improve this answer

Your Answer


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.