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:
To clear the messages in the queue for the recipient:
Get-ExchangeServer |?{$_.IsHubTransportServer -eq $true} |Get-Queue |get-message -ResultSize unlimited |?{$_.recipient -eq
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