As you may have noticed, I currently do focus more on cloud technologies, in particular Microsoft 365. The way I see it is that on-premise computing will slowly be fading away and cloud computing will be the leading-edge technology. Suprise, suprise, this blog post is again about Microsoft 365. I will show you how to list all mailboxserver forwarding rules.
First of all, I want to point out that there are user created rules and that there are server rules created by mailbox or Microsoft 365 administrators. In this blog post I will carry out listing forwarding rules created in Exchange Online, respectively those rules created by administrators.
Connect to Microsoft 365 / Exchange Online
First we need to connect to our tenant. Run the commands below to open a PowerShell session to your Microsoft cloud.
Install-Module -Name ExchangeOnlineManagement -Force -AllowClobber Connect-ExchangeOnline -UserPrincipalName user@domain.com -ShowProgress $true
Fine. Let’s move on.
Listing Mailbox Forwarding Rules
Copy and paste the code below into your Microsoft 365 PowerShell session to list all mailbox server forwarding rules.
Get-Mailbox -ResultSize Unlimited ` -Filter "ForwardingAddress -like '*' -or ForwardingSmtpAddress -like '*'" | Select-Object Name,ForwardingAddress,ForwardingSmtpAddress
For nicer output, you can pipe the command to any export- or out- cmdlet of your choosing, for example to ConvertTo-Html and Out-File.
Get-Mailbox -ResultSize Unlimited ` -Filter "ForwardingAddress -like '*' -or ForwardingSmtpAddress -like '*'" | Select-Object Name,ForwardingAddress,ForwardingSmtpAddress | ConvertTo-Html | Out-File $home\mailboxserverforwardingrules.htm Start-Process $home\mailboxserverforwardingrules.htm
This will show up the html file in a browser window.
Mission accomplished. Hope this was helpful.
See also
Microsoft 365: Show Mailboxes that have Auto-Reply enabled
Microsoft 365: Add User Accounts and Mailboxes with PowerShell
Categories: Microsoft 365, PowerShell
I have been sifting through the internet to find this exact thing. Thank you so much, this was extremely helpful.
LikeLike
Thank you!
LikeLike
Thanks Patrick, really helpful.
LikeLiked by 1 person
Thank you! Worked great!
LikeLiked by 1 person
You’re welcome
LikeLike
The article is very good, but how do you find out which boxes are being redirected to a specific user?
Example, I want to know all the boxes that are being redirected to my user, is it possible?
LikeLike
Very Helpful! Thanks.
LikeLiked by 1 person
Thank you!
LikeLike