Commands › Exchange Online

Test-Mailflow

Exchange Online ExchangeOnlineManagement Test-*

Diagnose whether mail can be successfully sent from and delivered to the system mailbox on a Mailbox server. You can also use this cmdlet to verify that email is sent between Mailbox servers within a defined latency threshold.

Quick start script

# Test-Mailflow — 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-Mailflow -AutoDiscoverTargetMailboxServer <SwitchParameter> -CrossPremises <Boolean> -TargetDatabase <DatabaseIdParameter> | Format-List

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

Syntax — 6 parameter sets

AutoDiscoverTargetMailboxServer

Test-Mailflow [[-Identity] <ServerIdParameter>]
 [-AutoDiscoverTargetMailboxServer]
 [-ActiveDirectoryTimeout <Int32>]
 [-Confirm]
 [-DomainController <Fqdn>]
 [-ErrorLatency <Int32>]
 [-ExecutionTimeout <Int32>]
 [-MonitoringContext <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

CrossPremises

Test-Mailflow -CrossPremises <Boolean>
 [-ActiveDirectoryTimeout <Int32>]
 [-CrossPremisesExpirationTimeout <EnhancedTimeSpan>]
 [-CrossPremisesPendingErrorCount <Int32>]
 [-Confirm]
 [-DomainController <Fqdn>]
 [-ErrorLatency <Int32>]
 [-ExecutionTimeout <Int32>]
 [-MonitoringContext <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

TargetDatabase

Test-Mailflow [[-Identity] <ServerIdParameter>] -TargetDatabase <DatabaseIdParameter>
 [-ActiveDirectoryTimeout <Int32>]
 [-Confirm]
 [-DomainController <Fqdn>]
 [-ErrorLatency <Int32>]
 [-ExecutionTimeout <Int32>]
 [-MonitoringContext <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

TargetEmailAddress

Test-Mailflow [[-Identity] <ServerIdParameter>] -TargetEmailAddress <String>
 [-TargetEmailAddressDisplayName <String>]
 [-ActiveDirectoryTimeout <Int32>]
 [-Confirm]
 [-DomainController <Fqdn>]
 [-ErrorLatency <Int32>]
 [-ExecutionTimeout <Int32>]
 [-MonitoringContext <Boolean>]
 [-WhatIf]
 [<CommonParameters>]

2 more parameter sets — see the parameter table below.

Parameters (16)

ParameterTypeRequiredWhat it controls
-Identity ServerIdParameter The Identity parameter specifies the source Mailbox server name from which a test message is sent. You can use any value that uniquely identifies the server. For example:
-AutoDiscoverTargetMailboxServer SwitchParameter yes The AutoDiscoverTargetMailboxServer switch specifies whether to automatically populate a list of target Mailbox servers to which to send a test message. You don't need to specify a value with this switch.
-CrossPremises Boolean yes The CrossPremises parameter specifies whether the mail flow test is conducted in cross-premises mode.
-TargetDatabase DatabaseIdParameter yes The TargetDatabase parameter specifies the mailbox database to which test messages are sent. You can use any value that uniquely identifies the database. For example:
-TargetEmailAddress String yes The TargetEmailAddress parameter specifies the SMTP address of the mailbox to which test messages are sent. Use this parameter to send test messages to a Mailbox server in a remote forest. If this parameter is used,...
-TargetMailboxServer ServerIdParameter yes The TargetMailboxServer parameter specifies one or more Mailbox servers in the local Exchange organization to send test messages to. You can use any value that uniquely identifies the server. For example:
-ActiveDirectoryTimeout Int32 The ActiveDirectoryTimeout parameter specifies the number of seconds that elapse before the task provides an informational message about the delay. The default value is 15 seconds.
-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.
-CrossPremisesExpirationTimeout EnhancedTimeSpan The CrossPremisesExpirationTimeout parameter is used when this cmdlet is run by Microsoft System Center Operations Manager 2007 agents for asynchronous monitoring. We don't recommend using this parameter when running...
-CrossPremisesPendingErrorCount Int32 The CrossPremisesPendingErrorCount parameter is used when this cmdlet is run by System Center Operations Manager 2007 agents for asynchronous monitoring. We don't recommend using this parameter when running this...
-DomainController Fqdn The DomainController parameter specifies the domain controller that's used by this cmdlet to read data from or write data to Active Directory. You identify the domain controller by its fully qualified domain name...
-ErrorLatency Int32 The ErrorLatency parameter specifies how long to wait for a test message to be delivered before an error event is logged in Microsoft System Center Operations Manager 2007. The default value when a test message is...
-ExecutionTimeout Int32 The ExecutionTimeout parameter specifies the maximum time that this task can run before the test is determined to be a failure. If no test message or delivery report arrives before this time expires, the task ends...
-MonitoringContext Boolean The MonitoringContext parameter specifies whether to include the associated monitoring events and performance counters in the results. Valid values are:
-TargetEmailAddressDisplayName String The TargetEmailAddressDisplayName parameter specifies a custom display name that's used on events and reports in Microsoft System Center Operations Manager 2007 when the TargetEmailAddress parameter is used. If you...
-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.