Forum Discussion

TH_'s avatar
TH_
Copper Contributor
Feb 15, 2022
Solved

Forward rule for all users

Hi everyone,

 

Looking for a clever way to set up a forward rule (all incoming traffic) for all our users from one tenant to another due to a recent acquisition. Was wondering if anyone knows of a powershell script or something similar to accomplish this? Thanks!

  • Most third-party t2t migration tools have some way to redirect mail flow, that should be your go-to option. Other than that, PowerShell is your friend - simple loop over all mailboxes, and set the forwarding address to the corresponding @newtenant.onmicrosoft.com address.

2 Replies

  • Most third-party t2t migration tools have some way to redirect mail flow, that should be your go-to option. Other than that, PowerShell is your friend - simple loop over all mailboxes, and set the forwarding address to the corresponding @newtenant.onmicrosoft.com address.
    • TH_'s avatar
      TH_
      Copper Contributor

      VasilMichev 

       

      I simply created a csv with UPN and the ForwardToAddr and imported that in the script below. Seems to have done the trick.

       

      $users = import-csv '.\UserMailboxes.csv'
      foreach ($user in $users)
      {
          Set-Mailbox $user.UPN -ForwardingSmtpAddress $User.FWD -force
       
          Write-Host "$($user.UPN) now forwards to ($user.FWD)"
      }
      $users = $null

       

Resources