How to generate list of user in exchange have a setup of email forwarding and also the recipient via powershell

JYLVEN TARRAJA 60 Reputation points
2025-01-27T07:05:14.4733333+00:00

Please help, how to generate a list via powershell. List of all user have a setup of Email forwarding and their recipients.

Thank you in advance

Exchange Server Management
Exchange Server Management
Exchange Server: A family of Microsoft client/server messaging and collaboration software.Management: The act or process of organizing, handling, directing or controlling something.
7,775 questions
Microsoft Exchange
Microsoft Exchange
Microsoft messaging and collaboration software.
650 questions
Windows Server PowerShell
Windows Server PowerShell
Windows Server: A family of Microsoft server operating systems that support enterprise-level management, data storage, applications, and communications.PowerShell: A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
5,609 questions
PowerShell
PowerShell
A family of Microsoft task automation and configuration management frameworks consisting of a command-line shell and associated scripting language.
2,762 questions
{count} votes

Accepted answer
  1. Jake Zhang-MSFT 8,400 Reputation points Microsoft Vendor
    2025-01-27T07:27:24.6233333+00:00

    Hi @JYLVEN TARRAJA ,

    Welcome to the Microsoft Q&A platform!

    According to your description, to generate a list of all users and their recipients who have set up email forwarding, you can use the following PowerShell script to generate a list of users and their recipients with mail forwarding settings:

    • Open the Exchange Management Shell.
    • Run the following script:
    # Get all mailboxes
    $mailboxes = Get-Mailbox -ResultSize Unlimited
    # Initialize an array to store the results
    $results = @()
    foreach ($mailbox in $mailboxes) {
    # Get the forwarding settings for the mailbox
    $forwardingAddress = $mailbox.ForwardingAddress
        $forwardingSmtpAddress = $mailbox.ForwardingSmtpAddress
    
        if ($forwardingAddress -or $forwardingSmtpAddress) {
            $results += [PSCustomObject]@{
                User                = $mailbox.UserPrincipalName
                ForwardingAddress   = $forwardingAddress
                ForwardingSmtpAddress = $forwardingSmtpAddress
            }
        }
    }
    # Export the results to a CSV file
    $results | Export-Csv -Path "C:\EmailForwardingList.csv" -NoTypeInformation
    

    This script creates a CSV file named EmailForwardingList.csv in the C:\ directory that contains a list of users and their forwarding addresses.


    Please feel free to contact me for any updates. And if this helps, don't forget to mark it as an answer.

    Best,

    Jake Zhang


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.