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

JYLVEN TARRAJA 80 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 | Exchange Server | Management
Exchange | Exchange Server | Management
The administration and maintenance of Microsoft Exchange Server to ensure secure, reliable, and efficient email and collaboration services across an organization.
Windows for business | Windows Server | User experience | PowerShell
Exchange | Other
Exchange | Other
A powerful email and collaboration platform developed by Microsoft, designed to support enterprise-level communication and productivity. Miscellaneous topics that do not fit into specific categories.
{count} votes

Answer accepted by question author
  1. Anonymous
    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' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.