MSP StockroomFind a guide, template or tool…/
Curated SOPs / Microsoft 365 and identity

M365 Curated SOP / Microsoft 365 and identity

Find mailbox forwarding that sends mail outside the client

Find every mailbox in a client's Exchange Online tenant that forwards or redirects mail, either through a forwarding address on the mailbox or through an inbox rule, and pick out the ones that send mail to addresses outside the client.

Low risk / Read-only / Reviewed December 1, 2026

Written and maintained by MSP Stockroom. Nobody else edits it.

On this page

Before you run anything: read every command first and understand what it does. Replace example names, domains and addresses with your own. Try it on a test device or tenant before a client's. Keep client names, passwords and keys out of tickets and chat.

Purpose

Find every mailbox in a client's Exchange Online tenant that forwards or redirects mail, either through a forwarding address on the mailbox or through an inbox rule, and pick out the ones that send mail to addresses outside the client. An attacker who gets into a mailbox often adds a hidden forward to keep reading mail after the password is changed. Use it in the first week with a new client, at each quarterly review, and whenever an account may have been compromised. Read-only: nothing in this SOP changes the tenant.

Scope and prerequisites

  • Run by the client's assigned engineer.
  • Needs an Exchange Online role that can run Get-InboxRule. Global Reader and the View-Only Organization Management role group cannot run it, so a read-only account is not enough for step 4. Step 1 shows which roles in the client's tenant can.
  • The Exchange Online PowerShell module installed from the PowerShell Gallery.
  • Store the results in your documentation platform, never in this library. Forwarding addresses are personal data; keep them out of tickets where you can.

Steps

  1. Connect, then check which roles can run Get-InboxRule if you are not sure your account has one:
    # You will be asked to sign in to the client's tenant.
    Connect-ExchangeOnline
    
    $roles = Get-ManagementRole -Cmdlet Get-InboxRule
    $roles | ForEach-Object {
        Get-ManagementRoleAssignment -Role $_.Name -Delegating $false |
            Format-Table -Auto Role, RoleAssigneeType, RoleAssigneeName
    }
  2. List the client's own domains. Any forwarding address outside these is external:
    Get-AcceptedDomain | Format-Table DomainName, DomainType
  3. List mailboxes with a forwarding address set on the mailbox itself:
    Get-EXOMailbox -ResultSize Unlimited -PropertySets Delivery |
        Where-Object { $_.ForwardingSmtpAddress -or $_.ForwardingAddress } |
        Select-Object UserPrincipalName, ForwardingSmtpAddress, ForwardingAddress,
            DeliverToMailboxAndForward

    Read the result:

    • ForwardingSmtpAddress set: mail is forwarded to an external address. Record it.
    • ForwardingAddress set: mail is forwarded to a recipient in the client's directory. Look that recipient up to see where it delivers.
    • Both set: mail goes only to ForwardingAddress.
    • DeliverToMailboxAndForward True: the user still gets a copy. False: mail is only forwarded, and the user never sees it. Treat False as more urgent.
  4. List inbox rules that forward or redirect mail, including hidden rules:
    Get-EXOMailbox -ResultSize Unlimited | ForEach-Object {
        $owner = $_.UserPrincipalName
        Get-InboxRule -Mailbox $owner -IncludeHidden -ResultSize Unlimited |
            Where-Object { $_.ForwardTo -or $_.RedirectTo -or $_.ForwardAsAttachmentTo } |
            ForEach-Object {
                [pscustomobject]@{
                    Mailbox               = $owner
                    Rule                  = $_.Name
                    Enabled               = $_.Enabled
                    ForwardTo             = $_.ForwardTo -join '; '
                    RedirectTo            = $_.RedirectTo -join '; '
                    ForwardAsAttachmentTo = $_.ForwardAsAttachmentTo -join '; '
                }
            }
    } | Sort-Object Mailbox, Rule

    Read the result:

    • Compare every address with the domains from step 2. An address outside them is external.
    • RedirectTo: mail goes to the new address and is not delivered to the mailbox.
    • Enabled False: the rule is off now, but record it, since it can be switched on.
  5. Check whether the tenant blocks automatic forwarding to outside addresses:
    Get-HostedOutboundSpamFilterPolicy | Format-Table Name, IsDefault, AutoForwardingMode

    Read the result:

    • Off: automatic external forwarding is blocked, and senders get a delivery failure. Forwards found above will not work, but they still show intent.
    • On: automatic external forwarding is allowed.
    • Automatic: the system decides. For most tenants this now means blocked, but older tenants that already used external forwarding may still be allowed.
  6. Disconnect when finished:
    Disconnect-ExchangeOnline

Verify

Every forward or rule that sends mail outside the client has a named owner at the client and a business reason. Anything without one goes to the client contact as a question, not a change. A forward you cannot explain, especially a hidden or redirecting one, is treated as a possible compromise and raised the same day under your incident process.

Rollback

Nothing to roll back; this SOP only reads. Removing a forward or a rule, or changing the outbound spam policy, is a separate change, made with the client's approval. If you suspect a compromise, follow Microsoft's guidance for a compromised account first, so evidence is kept.

Notes

The outbound spam policy only covers forwarding to outside addresses. Remote domain settings and mail flow rules can also block forwarding, and a block there usually wins. The Exchange admin center also has an auto forwarded messages report under mail flow reports, which shows forwarding that actually happened. Step 4 calls Exchange once per mailbox, so large tenants take a while. See https://learn.microsoft.com/defender-office-365/responding-to-a-compromised-email-account and https://learn.microsoft.com/defender-office-365/outbound-spam-policies-external-email-forwarding for Microsoft's guidance.

Sources and notes

Curated SOP from the MSP Stockroom SOP library (curated/m365-identity/find-mailbox-forwarding-to-external-addresses.md). Last reviewed December 1, 2026. Tested on: Not yet run; written for Exchange Online PowerShell module 3.x; PowerShell 7.4. Vendor screens and commands change; check the vendor documentation before you rely on a step. Found a mistake? See corrections.

Search the stockroom

↑ ↓ to choose · Enter to open · Esc to close

Open the full search page →