Commands › Exchange Online
Test-Message
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)
Reference facts derived from Microsoft documentation, © Microsoft, licensed CC BY 4.0; restructured with original guidance by serv365.ai.