Exchange Online: Setting mail forwarding with PowerShell

One of Exchange Online functionalities as part of the Office365 suite is the ability to forward mails to another mailbox or smtp address quick and easy using the users Office365 portal. Besides, what happens when you have to do it as an admin on 500 users at a time? it results tedious right?.

Well, we can do this quickly with the help of PowerShell with the following commands:

Forward mails to another mailbox:

Set-Mailbox user@domain.com -ForwardingAddress dest_mailbox@domain.com

Forward mailbox without saving a local copy:

Set-Mailbox user@domain.com -ForwardingAddress dest_mailbox@domain.com -DeliverToMailboxAndForward $false

Forwarding mails to another external mailbox:

Set-Mailbox user@domain.com -ForwardingSmtpAddress ext_mailbox@domain.com

Forwarding mails to another external mailbox without saving a local copy:

Set-Mailbox user@domain.com -ForwardingSmtpAddress ext_mailbox@domain.com -DeliverToMailboxAndForward $false

Apply the forwarding to users in mass:

Get-Mailbox | Where {$_.RecipientType -eq “UserMailbox”} | Set-Mailbox -ForwardingAddress dest_mailbox@domain.com

Apply the forwarding to users to be sent to external users in mass:

Get-Mailbox | Where {$_.RecipientType -eq “UserMailbox”} | Set-Mailbox -ForwardingSmtpAddress ext_mailbox@domain.com

Get forwarding Info of a user:

Get-Mailbox -Identity user@domain.com | fl DeliverToMailboxAndForward, ForwardingAddress, ForwardingSmtpAddress

Remove mail forwarding:

Set-Mailbox user@domain.com -ForwardingAddress $null

Remove mail forwarding sent to an external user:

Set-Mailbox user@domain.com -ForwardingSmtpAddress $null

Remove mail forwarding to users in mass:

Get-Mailbox | Where {$_.RecipientType -eq “UserMailbox”} | Set-Mailbox -ForwardingAddress $null

Remove mail forwarding sent to external users to users in mass:

Get-Mailbox | Where {$_.RecipientType -eq “UserMailbox”} | Set-Mailbox -ForwardingSmtpAddress $null

Advertisements

One thought on “Exchange Online: Setting mail forwarding with PowerShell

  1. Pingback: Top 3 Reasons Your Online Business Needs A Mail Forwarding Service | web blog

Leave a Reply