# NewTransportRuleExecName.ps1

  • Purpose
  • Dependencies
  • Function
  • Usage
  • Inputs
  • Variables
  • Command Line Flags
  • Outputs
  • Notes

# Purpose

Creates or updates a specific Exchange Online transport rule to prepend a disclaimer for messages sent from outside the organisation by someone with a display name matching a user in your organisation. Designed to help prevent impersonation attacks.

# Dependencies

# Function

  1. Connects to Exchange Online using Connect-ExchangeOnline.
  2. Searches for an existing transport rule by name.
  3. If the rule does not exist, creates it with a specific HTML disclaimer and pattern matching.
  4. If the rule exists, updates it with the latest disclaimer and settings.
  5. Uses hardcoded display name(s) for pattern matching (can be extended for dynamic mailbox display names).
  6. Provides console feedback for each step.

# Usage

./NewTransportRuleExecName.ps1

The script is interactive and does not require command-line parameters for standard use. Rule name and disclaimer are set within the script.

# Inputs

None for standard use. (Rule name, disclaimer, and display names are set in the script.)

# Variables

  • $ruleName: Name of the transport rule
  • $ruleHtml: HTML disclaimer to prepend
  • $displayNames: Display names to match for impersonation protection

# Command Line Flags

None for standard use.

# Outputs

  • Creates or updates the specified transport rule in Exchange Online
  • Provides console feedback for each step

# Notes

  • Requires the Exchange Online Management module
  • Script can be extended to dynamically gather display names from all active mailboxes