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 email@example.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.