Let's say that you have a loop because someone setup an INBOX RULE to forward to an outside domain that is having problems.
How do you clear the queue of 1M messages that show as a result?
To clear the incoming messages that have arrived in the inbox:
Get-Mailbox account.name | Search-Mailbox -SearchQuery {from: This e-mail address is being protected from spambots. You need JavaScript enabled to view it } -DeleteContent
To clear the messages in the queue for the recipient:
Get-ExchangeServer |?{$_.IsHubTransportServer -eq $true} |Get-Queue |get-message -ResultSize unlimited |?{$_.recipient -eq ' This e-mail address is being protected from spambots. You need JavaScript enabled to view it '} |Remove-Message -WithNDR $False -Confirm $False
To clear the messages in the queue for the postmaster <>:
Get-ExchangeServer |?{$_.IsHubTransportServer -eq $true} |Get-Queue |get-message -ResultSize unlimited |?{$_.sender -eq '<>'} |Remove-Message -WithNDR $False -Confirm $False