
List All Office 365 Mailboxes that Forward Emails to a Specific User
Getting a list of Office 365 mailboxes with a forward is accessible. But in some situations, admins want to know a list of Office 365 mailboxes that forward emails to a specific user. For example, when an employee leaves an organization, admins need to identify the automatic email forwarding to that user and replace the user with a new one.
How to Get All Mailboxes that Forward to a Specific User?
Suppose you try to identify automatic email forwarding to a specific recipient. In that case, you can use either the Exchange admin center or PowerShell. But in EAC, you need to click each mailbox to know the mailbox forwarding details, which is not possible for a larger environment. So, PowerShell is the best solution for both smaller and larger organizations.
Get All Mailboxes that Forward Emails to a Particular User using PowerShell:
Mailboxes store email forwarding configuration in the ‘ForwardingAddress’ property. So, we need to loop through all mailboxes and identify the ‘ForwardingAddress’ that matches the target user.
Here, Exchange Online uses Canonical name format to store the forwarding address. So, we need to provide the canonical name of the user. If you are not sure about it, do not worry! Our script will automatically convert the UPN to Canonical name and identify the mailboxes that auto-forward emails to a particular user.
You must install the Exchange Online PowerShell module to run the script below.
Connect-ExchangeOnline $RecipientIdentity=(Get-Recipient <RecipientUPN>).Identity Get-Mailbox | where {$_.ForwardingAddress -eq $RecipientIdentity} | select Name, Alias
It will list all the mailboxes’ names and aliases that forward emails to a specific user. The above code will consider only a ‘ForwardingAddress’. When a user configures email forwarding from Outlook, it will be stored in the ‘ForwardingSMTPAddress’ property.
If you want to consider ‘ForwardingSMTPAddress’ too, you can use the below code.
Connect-ExchangeOnline $UPN=<UPN> #UPN should be enclosed between double quotes $RecipientIdentity=(Get-Recipient $UPN ).Identity Get-Mailbox | where {($_.ForwardingAddress -eq $RecipientIdentity) -or ($_.ForwardingSMTPAddress -match $UPN) } | select Name, Alias
Microsoft 365 provides a few more ways to configure automatic email forwarding, such as inbox rules, transport rules, etc. Isn’t it hard to identify email forwarding rules?
List All Office 365 Mailboxes with Email Forwarding:
To get a report on mailboxes with a forwarding configuration (By considering all the possible ways), you can download the script to generate Office 365 email forwarding report.
Script Highlights:
- Generates 3 different email forwarding configuration reports.
- Automatically installs the Exchange Online module upon your confirmation when it is not available on your machine.
- Shows mailboxes in which email forwarding is configured through ‘Forwarding SMTP Address’ and ‘Forward To’.
- Lists all inbox rules that forward the emails to other mailboxes.
- Identifies transport rules that redirect emails to mailboxes
- Supports both MFA and Non-MFA accounts.
- Exports report result to CSV file.
- The script is scheduler-friendly. You can automate the report generation upon passing credentials as parameters.
Sample Output:
This script will provide 3 output file based on the given input. We have attached a few sample output formats.
Email forwarding report:
Inbox rules with email forwarding configuration:
I hope this blog will help you check email forwarding configurations in Office 365. By referring to these reports, admins can remove forwarding or block external email forwarding based on the organization’s security policy.