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...

link|improve this question

feedback

3 Answers

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?

link|improve this answer
feedback
Get-ExchangeServer | ?{$_.IsHubTransportServer -eq $true} | Get-Queue | get-message | Remove-Message -withNDR $false
link|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
feedback

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.

http://community.spiceworks.com/how_to/show/267

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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