PowerShell Genie

Find mailbox forwarding

Script 2 min read Windows PowerShell 5.1 and PowerShell 7

Documentation: Microsoft Learn

Get-EXOMailbox runs with -PropertySets All so the forwarding attributes come back, since they sit outside the minimal default set this cmdlet returns.

The script

1PS> Get-EXOMailbox -ResultSize Unlimited -PropertySets All | Where-Object ForwardingSmtpAddress | Select-Object DisplayName,PrimarySmtpAddress,ForwardingSmtpAddress

Script reader

Inspect before you run

Inspection only

Inspect the script below. It does not run in this browser.

Inspection only — no command has run.

    Show reference output
    1 DisplayName PrimarySmtpAddress ForwardingSmtpAddress
    2 ----------- ------------------ ---------------------
    3 Sample object user@example.test smtp:archive@example.test
    Inspect this example’s structure

    Read the command and its supplied arguments. This example requires real PowerShell or its module; this diagram does not execute it.

    Get-EXOMailbox -ResultSize Unlimited -PropertySets All | Where-Object ForwardingSmtpAddress | Select-Object DisplayName,PrimarySmtpAddress,ForwardingSmtpAddress
    1. Stage 1Get-EXOMailbox-ResultSize -PropertySets
    2. Stage 2Where-ObjectPositional values or no named parameters
    3. Stage 3Select-ObjectPositional values or no named parameters

      How it works

      Get-EXOMailbox runs with -PropertySets All so the forwarding attributes come back, since they sit outside the minimal default set this cmdlet returns. Where-Object keeps mailboxes with a populated ForwardingSmtpAddress, and the projection shows that destination next to the mailbox identity.

      Adapting it

      Check ForwardingAddress as well, which holds forwarding aimed at an internal recipient object, and add DeliverToMailboxAndForward to see whether a copy is still being kept in the original mailbox.

      Requirements

      ExchangeOnlineManagement module with a Connect-ExchangeOnline session.

      If the result is unexpected

      A mailbox forwarding report misses rule-based forwarding.

      Mailbox forwarding properties and inbox rules are separate configuration mechanisms.

      1. Inspect the mailbox forwarding properties and check inbox rules separately for the same mailbox.

      Validate the result

      The report identifies which forwarding mechanism produced each finding.

      Keep the check reliable

      Include both mechanisms when the audit question is about all configured forwarding.

      Primary documentation

      Microsoft 365, Entra and Azure documentation

      Continue
      Genie guideFind mailbox forwarding

      Get-EXOMailbox runs with -PropertySets All so the forwarding attributes come back, since they sit outside the minimal default set this cmdlet returns.