Powershell Migration Series | Setting bulk forwarding using powershell

Powershell Migration Series

Setting bulk forwarding using powershell

Whilst doing my migration, i want to set up the mailbox so that i can forward any new massages to O365 from the local exchange, after i have done the bulk of mail migration. In order to do this, we utilise the .onmicrosoft.com address space that O365 can provide each email user.

The plan is simple, forward mail from local exchange @contoso.com to O365 @contoso.onmicrosoft.com

Once you have created the contacts, the next step is Setting bulk forwarding using powershell

1) Create another CSV, this time in the following format,

DisplayName,MailAddress

DisplayName = the username in exchange, e.g. “Joe Bloggs”
Mail Address = Forwarding address @contoso.onmicrosoft.com address

Save it as “ForwardingAddresses.csv”

2) Run the following which creates the bulk forwarding using powershell

Import-Csv c:\scripts\ForwardingAddresses.csv | Foreach-Object{Get-Mailbox $_.DisplayName | Set-Mailbox -ForwardingAddress $_.MailAddress}

Now for me, i needed it to deliver to both the exchange mailbox and to forward to the O365 mailbox, if you need it to deliver to the mailbox AND forward, add the below switch to the end of the above before the last curley bracket }

-DeliverToMailboxAndForward $true

Final script i ran:

Import-Csv c:\ws\ForwardingAddresses.csv | Foreach-Object{Get-Mailbox $_.DisplayName | Set-Mailbox -ForwardingAddress $_.MailAddress -DeliverToMailboxAndForward $true}

Setting bulk forwarding using powershell

Powershell Migration Series | Creating bulk contacts with powershell

Powershell Migration Series

Creating bulk contacts with powershell

Whilst doing my migration, i want to set up the mailbox so that i can foward any new massages to O365 from the local exchange, after i have done the bulk of mail migration. In order to do this, we utilise the .onmicrosoft.com address space that O365 can provide each email user.

The plan is simple, forward mail from local exchange @contoso.com to O365 @contoso.onmicrosoft.com

To do so, on the local exchange there is two steps,

1) create CSV with the following format and your contact data:

Firstname,LastName,ExternalEmailAddress

Save as external_users.csv

2) Run the following which creates the bulk contacts with powershell

Import-Csv “C:\scripts\external_users.csv” | ForEach {New-MailContact -Name $_.Name -Firstname $_.FirstName -LastName $_.LastName -ExternalEmailAddress $_.ExternalEmailAddress -OrganizationalUnit “DOMAIN.local/MyBusiness/Users/SBSUsers/Contacts”}

replace: “DOMAIN.local/MyBusiness/Users/SBSUsers/Contacts” with the OU you wish the contacts to be created in.

Creating bulk contacts with powershell

You then need to set up the forwarding within exchange, now you have already done the contacts using powershell, why not set forwarding with powershell also?