Commands › Exchange Online

Test-Message

Exchange Online ExchangeOnlineManagement Test-*

This cmdlet is functional only in the cloud-based service. Use the Test-Message cmdlet to simulate and report on the effects of mail flow rules (transport rules) and unified DLP rules on test email messages. Because this cmdlet introduces email into the DLP evaluation pipeline, actions such as Block, Moderate, etc. can take place on the test message. Related notifications are also sent to any configured recipients.

Quick start script

# Test-Message — quick start (serv365.ai)
# 1. Connect (app-only shown; interactive: omit the certificate parameters)
Connect-ExchangeOnline -CertificateThumbprint $thumb -AppId $appId -Organization $org

# 2. Run and inspect
Test-Message -Recipients <ProxyAddressCollection> -SendReportTo <RecipientIdParameter> -TransportRules <SwitchParameter> | Format-List

# 3. Export for evidence / drift tracking
Test-Message | Export-Clixml .\Message-$(Get-Date -Format yyyyMMdd).xml

Syntax — 2 parameter sets

TransportRules

Test-Message -Recipients <ProxyAddressCollection> -SendReportTo <RecipientIdParameter> -TransportRules
 [-Confirm]
 [-Force]
 [-MessageFileData <Byte[]>]
 [-Sender <SmtpAddress>]
 [-UnifiedDlpRules]
 [-WhatIf]
 [<CommonParameters>]

UnifiedDLPRules

Test-Message -Recipients <ProxyAddressCollection> -SendReportTo <RecipientIdParameter> -UnifiedDlpRules
 [-Confirm]
 [-Force]
 [-MessageFileData <Byte[]>]
 [-Sender <SmtpAddress>]
 [-WhatIf]
 [<CommonParameters>]

Parameters (9)

ParameterTypeRequiredWhat it controls
-Recipients ProxyAddressCollection yes The Recipients parameter specifies the recipient email address to use for the test message.
-SendReportTo RecipientIdParameter yes The SendReportTo parameter specifies the target email address for the command results.
-TransportRules SwitchParameter yes The TransportRules switch specifies that you want to test mail flow rules. You don't need to specify a value with this switch.
-UnifiedDlpRules SwitchParameter yes The UnifiedDlpRules switch specifies that you want to unified DLP rules. You don't need to specify a value with this switch.
-Confirm SwitchParameter The Confirm switch specifies whether to show or hide the confirmation prompt. How this switch affects the cmdlet depends on whether the cmdlet requires confirmation before proceeding.
-Force SwitchParameter The Force switch specifies whether to suppress warning or confirmation messages. You can use this switch to run tasks programmatically where prompting for administrative input is inappropriate. You don't need to...
-MessageFileData Byte[] The MessageFileData parameter specifies the .eml message file to test.
-Sender SmtpAddress The Sender parameter specifies the sender email address to use for the test message.
-WhatIf SwitchParameter The WhatIf switch shows what the command does without making any changes. You don't need to specify a value with this switch.

Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.