Skip to content

Report email forwards

directorcia edited this page Jan 1, 2025 · 1 revision

Script = o365-exo-fwd-chk.ps1

Exchange Online Mailbox Forwarding Checker Script

Overview

This PowerShell script checks which email mailboxes in an Exchange Online environment have forwarding options set.


Detailed Explanation

Metadata and Documentation

  • Includes a disclaimer, description, source URL, and prerequisites.
  • Assumes the user is already connected to Exchange Online.

Variable Initialization

  • Initializes message color variables:
    • $systemmessagecolor
    • $processmessagecolor
    • $errormessagecolor
    • $warnmessagecolor

Clearing the Host

  • Clears the host screen using Clear-Host.

Starting Message

  • Displays a message indicating the script has started.

Operation

Retrieving Mailboxes

  1. Prints a message indicating the retrieval of all mailbox details is starting.
  2. Retrieves all mailboxes using the command:
    Get-Mailbox -ResultSize Unlimited
    Stores the result in the $mailboxes variable.
  3. Prints a message indicating mailbox retrieval is complete.

Checking Mailbox Forwards

  1. Prints a message indicating it is starting to check mailbox forwards.
  2. Iterates over each mailbox in the $mailboxes collection:
    • Prints the display name and primary SMTP address.
    • Checks if the DeliverToMailboxAndForward property is True:
      • If True, indicates that email forwarding is active.
      • Prints forwarding status and forwarding SMTP address in red.

Results Interpretation

The script uses color-coded messages to represent mailbox forwarding status:

  • Green: No forwarding enabled and no forwarding address present.
  • Yellow: Forwarding disabled but forwarding address present.
  • Red: Forwarding enabled.

Purpose

This script helps administrators identify mailboxes with email forwarding enabled, providing a clear view of forwarding configurations in their Exchange Online environment. The output includes color-coded feedback and detailed information for each mailbox.