Manage Quarantined Messages in the Security and Compliance Center via PowerShell

Scenario: You want to start managing the Microsoft Online Quarantine via PowerShell. Its about time! The Microsoft GUI doesn’t play nice with wildcard queries.

First, you need to have the Exchange Online PowerShell Module, or another PS method to connect-IPPSSession.

Once you are connected to the Security and Compliance Center via PowerShell, you can run commands similar to this:

Get Quarantined Emails
Get-QuarantineMessage -StartReceivedDate 1/14/2021 -EndReceivedDate 1/16/2021 | FL

Get-QuarantineMessage -StartReceivedDate 1/14/2021 -EndReceivedDate 1/16/2021 -Type transportrule | Where SenderAddress -like *@gmail.com




Loop with Pages for Quarantined Messages
$P = 1
$messages = $null
do
{
Write-Host “Message Trace – Page $P…”
$temp_Messages = Get-QuarantineMessage -StartReceivedDate 1/15/2021 -EndReceivedDate 1/16/2021 -Type transportrule -page $p -pagesize 50
$P++
$Messages += $temp_Messages
}until ($temp_Messages -eq $null)




Release Quarantined Emails
Get-QuarantineMessage -StartReceivedDate 1/14/2021 -EndReceivedDate 1/16/2021 -Type transportrule | Where SenderAddress -like *@gmail.com | Release-QuarantineMessage -ReleaseToAll







Advertisement

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: