Obtaining a list of all mailboxes set to forward to an alternate address has become common in my work environment recently. In the case where the account is set to both store and forward it’s somewhat easy to forget that messages are being forwarded to alternate addresses. Below is the basic command for determining accounts that are setup to forward. There are several variations of the command you can utilize.
Get-Mailbox | Where {$_.ForwardingAddress -ne $null} | Select Name, PrimarySMTPAddress, ForwardingAddress, DeliverToMailboxAndForward
The results will look like this:
If you want to list all of the mailboxes that do not have a forwarder setup you can run the following command:
Get-Mailbox | Where {$_.ForwardingAddress -eq $null} | Select Name, PrimarySMTPAddress, Alias, Displayname > c:\reports\nonforwarding.txt
This will send the results to a file called nonforwarding.txt in c:\reports
I’m messing with Office 365 on the Exchange Online plan. I believe this is querying my local domain controller. I’m waiting to hear back from Microsoft tech support about why forwarding settings seem to randomly disappear from one of my accounts. And with this command, I can quickly see exactly which addresses have forwarding on and to which address. Big thanks.
Get-Mailbox | Where {$_.ForwardingSMTPAddress -ne $null} | Select Name, PrimarySMTPAddress, ForwardingSMTPAddress, DeliverToMailboxAndForward