Migrate Exchange 2007, 2010 Public Folders to Office 365

So, you are looking to complete a migration from Exchange to Office 365, you’ve managed to fairly easily migrate all of your mailboxes but now it’s time to migrate your organisations public folders and you can’t find any options in the UI to migrate them. I’ve got some good and bad news for you, the good news is that it is possible to migrate the public folders, the bad news is that if you don’t want to use 3rd Party Software this is going to be by far the most complicated stage of your Office 365 Migration. The reason that migrating public folders to Office 365 is such a pain is that Microsoft actually tried to kill off Public folders when they brought out Exchange Online, when it first launched, public folders were completely missing. After a fair amount of uproar Microsoft brought public folder support back, I’ll warn you now though, it’s a bit messy.

 

Migrating public folders to Office 365 can be boiled down to 10 stupidly overcomplicated steps:

  • Download the Migration Scripts
  • Update Exchange Server
  • Prepare Exchange Server
  • Prepare Exchange Online
  • Generate the Migration Files
  • Generate the Public Folder Mailboxes in Exchange Online
  • Start the Migration Request
  • Lock down the public folders on the old server
  • Finalize the public folder migration
  • Test and Unlock Public Folder Migration

You are in for a bumpy ride!

Download the Migration Scripts

Unfortunately, there is no easy tool provided by Microsoft to do the migration, we must use a collection of PowerShell scripts and cmdlets to do the work for us.

Download all the following scripts;

Save them all to C:\PFScripts feel free to change this location but make sure all the scripts are in the same place.

Update Exchange Server

Only the following versions of Exchange server are supported by these scripts

  • Exchange 2010 with SP3 and at least RU8
  • Exchange 2007 with SP3 and at least RU15

If you don’t have these versions of Exchange you will have to upgrade and unfortunately if you have Exchange 2003 you can’t migrate your public folders to Exchange Online.

Prepare Exchange Server

You need to follow the following steps on your Exchange server before attempting the migration, if you miss any of these the scripts won’t work properly.

General Steps:

  • Make sure no orphaned public folders exist in AD (i.e. there are AD Objects for public folders that no longer exists)
  • Check that the SMTP address for any public folder objects in Exchange match the AD Objects
  • Remove any duplicate public folder objects in AD (If you have performed say a 2003 to 2007 public folder migration before it's common to have something like "FolderName" & "FolderName54334533" in AD for the same public folder
Exchange Server Steps

Run the through the following steps on the Exchange Server that you are migrating the public folders from

  1. We have to add the onmicrosoft domain for your 365 tenant to the Exchange server. To do this open the Exchange Shell as an administrator and type this
    New-AcceptedDomain -Name "PublicFolderDestination_OnMicrosoft" -DomainName example.onmicrosoft.com -DomainType InternalRelay
  2. We need to find any public folder names with backslashes in, to do this,
    1. On Exchange 2010 run
      Get-PublicFolderStatistics -ResultSize Unlimited | Where {($_.Name -like "*\*") -or ($_.Name -like "*/*") } | Format-List Name, Identity
    2. On Exchange 2007 run
      Get-PublicFolderDatabase | ForEach {Get-PublicFolderStatistics -Server $_.Server | Where {$_.Name -like "*\*"}}
    3. Then simply remove the backslash from any folders that it finds.
  3. Make sure there isn’t any remnants of a previous failed or successful Public Folder Migration
    1. Run this command to check the Public Folder Migration Status
      Get-OrganizationConfig | Format-List PublicFoldersLockedforMigration, PublicFolderMigrationComplete
    2. If either PublicFoldersLockedforMigration or PublicFolderMigrationComplete shows as $true then you need to run this to reset the value
      Set-OrganizationConfig -PublicFoldersLockedforMigration:$false -PublicFolderMigrationComplete:$false
    3. Once you’ve reset the migration status you have to wait for these settings to refresh in Exchange, this could take a couple of hours.
  4. If you are using Azure AD connect you must remove public folder objects from the sync.
    1. Open Azure AD Connect
    2. Under Additional Task select Customize Synchronization options
    3. Enter your credentials
    4. On the Optional Features screen make sure the Exchange Mail Public Folders is unticked
Prepare Exchange Online

Now that the Exchange Server is ready to go it’s time to move onto setting up Exchange Online.

  1. Make sure there are no pre-existing public folder migration requests, if there are delete them.
  2. Check that there are no public folder mailboxes already in Exchange Online, if there are check for existing public folders. You will want to remove any public folders and public folder mailboxes before carrying on.
Generate the migration files

Time to dig out those scripts! Create a folder called C:\PFMigration and then open an Exchange Management shell change directory to the scripts directory (C:\PFScripts) now run the following scripts

  1. .\Export-PublicFolderStatistics.ps1 "C:\PFMigration\foldertosizemap.csv" "exchangeserver.domain.local"
    (make sure to change the name here to the name of your server)
  2. .\PublicFolderToMailboxMapGenerator.ps1 16106127360 "C:\PFMigration\foldertosizemap.csv" "C:\PFMigration\foldertomailboxmap.csv"

Have a look through your folder to mailbox map file, if there are more than 1000 rows you will need to simplify your public folder layout.

Generate the Public Folder mailboxes in Exchange Online

Next, we need to create the public folder mailboxes in Exchange Online, these mailboxes are what actually host the content for your public folders. To do this it’s more PowerShell commands so open up the Exchange shell and run

.\Create-PublicFolderMailboxesForMigration.ps1 -FolderMappingCsv C:\PFmigration\foldertosizemap.csv -EstimatedNumberOfConcurrentUsers:<estimate>

Update the estimate with the max number of concurrent users you expect, this isn’t massively important but it might help performance in bigger organisations.

Start the Migration Request

Up until now everything has been prep work for this stage, now it’s time to start syncing our data.

  1. Synchronize the mail enabled public folders, run this on the old Exchange server. Use your Office 365 Admin account credentials when prompted.
    Sync-MailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile:C:\PFMigration\synclog.csv
  2. We need to get some more information before we can run the migration
    1. Find the LegacyExchangeDN of your Exchange Admin account
      Get-Mailbox <ExchangeAdminAccount> | Select-Object LegacyExchangeDN
    2. Get the ExchangeLegacyDN of the Mailbox Server that hosts the public folder database
      Get-ExchangeServer <exchangeservername> | Select-Object -Expand ExchangeLegacyDN
    3. Find the FQDN of the Outlook anywhere URL.
      Get-OutlookAnywhere | Format-Table Identity,ExternalHostName
  3. Now switch to Office 365 PowerShell, it’s time to update the info we just got into Exchange Online, first we need to set some values, then we can actually create the migration request!
    1. Get the credential of the old Exchange server admin
      $Source_Credential = Get-Credential domain\exchangeadmin
    2. Get the Legacy Exchange DN from above for this same user
      $Source_RemoteMailboxLegacyDN = "userDNgoeshere"
    3. Get the Legacy Exchange DN for the server from above
      $Source_RemotePublicFolderServerLegacyDN = "serverDNgoeshere"
    4. Get the FQDN for Outlook Anywhere from above
      $Source_OutlookAnywhereExternalHostName = "OutlookFQDN"
  4. At last, we can create the migration request (again in Office 365 Shell)
    $PfEndpoint = New-MigrationEndpoint -PublicFolder -Name
    PublicFolderEndpoint -RPCProxyServer
    $Source_OutlookAnywhereExternalHostName -Credentials $Source_Credential
    -SourceMailboxLegacyDN $Source_RemoteMailboxLegacyDN
    -PublicFolderDatabaseServerLegacyDN

    $Source_RemotePublicFolderServerLegacyDN -Authentication Basic

    [byte[]]$bytes = Get-Content -Encoding Byte
    C:\PFMigration\foldertomailboxmap.csv


    New-MigrationBatch -Name PublicFolderMigration -CSVData $bytes
    -SourceEndpoint $PfEndpoint.Identity -NotificationEmails email@domain.com
  5. Finally, start the migration process
    Start-MigrationBatch PublicFolderMigration

We are getting there! But don’t say I didn’t warn you about this being a complicated process. At this stage, we can actually use the EAC to check in on the Migration Process

  1. Login to EAC (Office 365)
  2. Go to Mailbox -> Migration
  3. Find the migration that you just created and click view details

Only 3 steps left!

Lock down the public folders on the old Exchange server

Now we need to stop users updating, editing and accessing the old public folders, we don’t want them to make any changes that won’t be synced. Depending on a few factors the migration process could take a while (how much data you have, Exchange performance, bandwidth etc..) and during this time Public Folders will effectively be offline, any mail that comes in for them will remain queued and users will have no access. You may need to make provisions for this. So back to the shell (old Exchange server).

Set-OrganizationConfig -PublicFoldersLockedForMigration:$true

Public folders are now locked, if you have multiple public folder servers you will have to wait for them to replicate before continuing.

Finalize the migration

We are so close at this point I can practically taste it, time to finish the migration. Once you run this command, Exchange does one final sync of the data and then that’s it. In 365 Shell run this

Complete-MigrationBatch PublicFolderMigration

If you have Hybrid Exchange you will also need to run this

Set-OrganizationConfig -RemotePublicFolderMailboxes $Null -PublicFoldersEnabled Local
Test the migration and unlock the public folders for users

We are finally done, time to test! Run all these commands in 365 Shell.

Run this command to give yourself access to the public folders.

Set-Mailbox -Identity <Test User> -DefaultPublicFolderMailbox <Public Folder Mailbox Identity>

Login to outlook, if the public folders look ok to you then it’s time to give everyone else access.

Get-Mailbox -PublicFolder | Set-Mailbox -PublicFolder -IsExcludedFromServingHierarchy $false

Everyone will now have access to the public folders through outlook (assuming they had permissions to do so before the migration). Finally run this command

Set-OrganizationConfig -PublicFoldersEnabled Local

That’s it. Done.

 

If you do not want to go through this tiresome process, then you can always choose a much safer option - a third-party tool like Kernel Migrator for Exchange which conducts a flawless public folder to Office 365 migration. With this Exchange Migration tool, You can choose to run a pre-migration analysis to know the possible migration time. Also, it synchronizes source and destination data and migrates limits and permissions too.

 


 

Related Software

Migrate Exchange 2007, 2010 Public Folders to Office 365

Try it free    See Pricing