Run the following command. This will display what messages are in a particular queue at the time you run the command.
Get-Message | fl
Results will show as follows:
[PS] C:\Windows\system32>Get-Message | fl
RunspaceId : 883bd636-74ec-4369-9600-bd4160974776 Subject : Email Message InternetMessageId : <[email protected]> FromAddress : [email protected] Status : Retry Size : 7.984 KB (8,176 bytes) MessageSourceName : FromLocal SourceIP : 255.255.255.255 SCL : -1 DateReceived : 12/19/2012 9:38:30 AM ExpirationTime : 12/21/2012 9:38:30 AM LastError : 420 4.2.0 RESOLVER.ADR.Ambiguous; ambiguous address RetryCount : 0 Recipients : ComponentLatency : MessageLatency : 04:00:48.2666165 DeferReason : Ambiguous Recipient Priority : Normal MessageIdentity : mailserver\Submission\16656 Queue : mailserver\Submission Identity : mailserver\Submission\16656 IsValid : True
Verify which message you want to delete. In this case there was a single message in the submission queue. Take note of the “Message Identity” as it will be used to delete the message in the next command
MessageIdentity : mailserver\Submission\16656
Now that you have the message identity you can run the follwoing command to delete it
[PS] C:\Windows\system32>Remove-Message -Identity mailserver\Submission\16656
Confirm Are you sure you want to perform this action? Removing the message “mailserver\Submission\16656”. [Y] Yes [A] Yes to All [N] No [L] No to All [?] Help (default is “Y”): y [PS] C:\Windows\system32>
Press Y and the message will be removed from the queue
Thanks for the detailed walkthrough. It helped me out today!