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

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
add comment

3 Answers 3

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
add comment
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
add comment

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

share|improve this answer
add comment

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.