Powershell - Manage EXO Quarantine queue

 So I was using the GUI for the quarantine queue in EXO and noticed its slow and full and bugs, so I though lets switch to PowerShell, and yes its nicer - wayyyyy nicer and can you can release messages in more than 100 blocks.

First connect to Exchange online, skip the first line if not proxy is required:

$ProxyOptions = New-PSSessionOption -ProxyAccessType ieconfig
Connect-ExchangeOnline -PSSessionOption $ProxyOptions

Once connected you have this PowerShell command:


If you want to see messages from a certain sender that have been blocked, then you can run this:

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com

If you only wish to see the same messages that have been released, use this

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com -ReleaseStatus 1

If you have more than the default 100 messages to check, then use this to show the maximum of 1000:

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com -PageSize 1000

Then finally if you wish to see which messages from that sender have not been released then run this command:

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com -ReleaseStatus 0 -PageSize 1000

Right, now this is working, we have all the messages that need to be released to users in this query, now we need to release them so this is simple the command for this is


However that is missing some variables, and the command on its own will not release lots of e-mails in the queue, this is where we need to add pipe the command, so take our command from above and then pipe this variable on to it......

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com -ReleaseStatus 0 -PageSize 1000 | Release-QuarantineMessage

If you did that, you will get a sea of red errors which is bad, but the error tells you where the issue is:

Message 'be6abdba-20aa-47c9-e9ce-08d97e8bd212\\43c642d0-f6bc-07ab-a0e3-55113c3e6b65' could not be released. You must either release the message to all recipients or to specific ones.

Right, so we missed off a variable required for this, we need to tell the command who gets the release message, as my message is to each individual this will fix that issue:

That variable is -ReleaseToAll, so lets add that.....

Get-QuarantineMessage -SenderAddress nobears@fluffyunicorns.com -ReleaseStatus 0 -PageSize 1000 | Release-QuarantineMessage  -ReleaseToAll

Right, that will then clear all the messages from the queue without doing them in 100 batches using the GUI, however if you have more than 1000 messages, once this command finishes as it only looks for "unreleased" messages you can run the command again for the next 1000 messages.