Short but useful script to set forwarding email address for every user in your Office 365 tenant. Can be useful for example if a company have been acquired, and the new owners want them to use theire email domain. Forwarding can then be a good temporary/quick fix to catching all emails to the old domain.
$Mailboxes = Get-Mailbox | Select-Object identity,alias Foreach($Mailbox in $Mailboxes) { $MailAlias = $Mailbox.alias Set-Mailbox -identity $Mailbox.identity -ForwardingSMTPAdress $MailAlias+"@contoso.com" }