Extract All Office 365 Forwarding to Import into New Tenant

#Export
Get-Mailbox -Filter {ForwardingAddress -ne $null -or ForwardingSmtpAddress -ne $null} |
Select-Object DisplayName, UserPrincipalName, ForwardingAddress, ForwardingSmtpAddress, DeliverToMailboxAndForward |
Export-Csv -Path "C:\EmailForwarding.csv" -NoTypeInformation -Encoding UTF8
#Import
$forwardingData = Import-Csv -Path "C:\EmailForwarding.csv"

foreach ($row in $forwardingData) {
    Set-Mailbox -Identity $row.UserPrincipalName `
        -ForwardingSmtpAddress $row.ForwardingSmtpAddress `
        -DeliverToMailboxAndForward $row.DeliverToMailboxAndForward
}
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading...