Public folder to Office 365

How to Migrate Public Folder to Office 365

We are using the Public Folder feature of Microsoft Exchange for a long time, whereas Office 365 was introduced more recently. Many people have the requirement to migrate the Public folder to Office 365. I hope this post will prove helpful in getting their requirement fulfilled. In this write-up, we will discuss the process of Public folder Migration into Office 365 step by step. So, let’s elaborate.

Words of Warning: If you’re a non-technocrat, then I suggest directly read the second method.

Move Public folder to Office 365

To Migrate public folders to Office 365, you need to be on the below-given version/cumulative update:

  • Exchange Server 2013 CU15 or higher
  • Microsoft Exchange Server 2016 CU4 or higher
  • Exchange Server 2019 No other CU prerequisites as all versions are supported.
  • If you are running in coexistence mode (Exchange 2013 coexisting with Exchange 2016 or Exchange 2019), Ensure that Exchange 2013 is on CU15 or above.

There are few other prerequisites for Public folder migration to Office 365, which you can check here. Now let’s start the process to migrate the Public folder to Office 365.

Step1: Download the Migration Scripts

Firstly, download all the migration scripts from here and save them in a folder.

Step2: Prepare Exchange Server for Migration

Add your Target domain (Office 365 domain) to your local server. For the same, run the following command.

New-AcceptedDomain -Name PublicFolderDestination_78c0b207_5ad2_4fee_8cb9_f373175b3f99 -DomainName<target domain> -DomainTypeInternalRelay


New-AcceptedDomain -Name PublicFolderDestination_78c0b207_5ad2_4fee_8cb9_f373175b3f99 -DomainName "" -DomainTypeInternalRelay

Now check if any of the public folders contain a backlash in the name, then Remove it. Run the following command to find the Public folders that have backlash.

Get-PublicFolder -Recurse -ResultSize Unlimited | Where {$_.Name -like "*\*" -or $_.Name -like "*/*"} | Format-List Name, Identity, EntryId

To Rename the Public folder with backlash, use the following command:

Set-PublicFolder -Identity "<public folder EntryId>" -Name "<new public folder name>"

Now check for the previous Migration process status by running the following command. (This step is only required if you are redoing previous migration, otherwise, skip to the next step)

Get-OrganizationConfig | Format-List PublicFolderMailboxesLockedForNewConnections, PublicFolderMailboxesMigrationComplete

If there is any successful previous migration, then set the value to false.

Set-OrganizationConfig -PublicFolderMailboxesLockedForNewConnections:$false -PublicFolderMailboxesMigrationComplete:$false

Step3: Now verify the success of the Public folder migration to Office 365.

Run the following command to snapshot the original public folder structure. So, you can use this snapshot to compare with newly migrated public folders.

Get-PublicFolder -Recurse -ResultSize Unlimited | Export-CliXML OnPrem_PFStructure.xml

To snapshot the statistics (Item count, Folder size, and owner) of the Public folder, run following script

Get-PublicFolderStatistics -ResultSize Unlimited | Export-CliXML OnPrem_PFStatistics.xml

Run the following command to snapshot of Public folder permissions

Get-PublicFolder -Recurse -ResultSize Unlimited | Get-PublicFolderClientPermission | Select-Object Identity,User,AccessRights -ExpandPropertyAccessRights | Export-CliXML OnPrem_PFPerms.xml

To snapshot your email enabled folder, run the following command:

Get-MailPublicFolder -ResultSize Unlimited | Export-CliXML OnPrem_MEPF.xml

Save all the generated files in a secure location to compare them once the public folder migration to Office 365 gets completed.

Step4: Prepare Office 365 account:

Ensure there is no existing public folder migration request in Office 365.

To find any existing public folder migration, run the following command:

Get-MigrationBatch| ?{$_.MigrationType.ToString() -eq "PublicFolder"}

If you find any batch migration request, then run the following command to remove it.

Remove-MigrationBatch<name of migration batch> -Confirm:$false

Step5: Create the CSV files (migration files):

Use the scripts downloaded in the 1st step. If you have already performed public folder migration to Office 365, only generate the CSV files given below:

To create the folder name to folder size mapping file, run the following command.

.\Export-ModernPublicFolderStatistics.ps1 <Folder-to-size map path>


.\Export-ModernPublicFolderStatistics.ps1 mailboxstats.csv

Run the following script to create a CSV file that will map your source public folder with the Office 365 Public folder.

.\ModernPublicFolderToMailboxMapGenerator.ps1 <Maximum mailbox size in bytes><Maximum mailbox recoverable item size in bytes><Folder-to-size map path><Folder-to-mailbox map path>


.\ModernPublicFolderToMailboxMapGenerator.ps1 -MailboxSize 30GB -MailboxRecoverableItemSize 2GB -ImportFile .\mailboxstats.csv -ExportFile mapping.csv

Step6: Create a Public folder in Office 365:

Now, create the target public folder in Office 365 to contain your migrate Exchange Server public folders.

Run the following script to create the target public folder mailbox in Office 365.

$mappings = Import-Csv <Folder-to-mailbox map path>
$primaryMailboxName = ($mappings | Where-Object FolderPath -eq "\" ).TargetMailbox;
New-Mailbox -HoldForMigration:$true -PublicFolder -IsExcludedFromServingHierarchy:$false $primaryMailboxName
($mappings | Where-Object TargetMailbox -ne $primaryMailboxName).TargetMailbox | Sort-Object -unique | ForEach-Object { New-Mailbox -PublicFolder -IsExcludedFromServingHierarchy:$false $_ }

The above script will create a public folder for each mailbox in the CSV file you generated earlier.

Step7: Start the migration:

Now, a number of commands have to run to start the migration.

Go to Local Exchange Server and access the Exchange management shell. Then, Run the following script to synchronize the email-enabled public folder from the local Active Directory to Office 365.

.\Sync-ModernMailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile:sync_summary.csv

Now in Office 365 PowerShell, Provide the credentials of users who have administrative rights in Exchange on-premises.

$Source_Credential = Get-Credential <source_domain>\<PublicFolder_Administrator_Account>

Then, provide the Internet routable fully qualified domain name (FQDN) of your Exchange mailbox Replication Service (MRS)

$Source_RemoteServer = "<MRS proxy endpoint server>"

Then, open the Exchange management shell in Office 365 and run the following command to find the globally unique identifier (GUID) of the primary hierarchy.


91edc6dd-478a-497c-8731-b0b793f5a986 will be the above command output copy it as you will need it in the next step.

Then, run the following script to create the public folder and migration endpoint and migration request for the Public folder.

[byte[]]$bytes = Get-Content -Encoding Byte <folder_mapping.csv>
$PfEndpoint = New-MigrationEndpoint -PublicFolder -Name PublicFolderEndpoint -RemoteServer $Source_RemoteServer -Credentials $Source_Credential
New-MigrationBatch -Name PublicFolderMigration -CSVData $bytes -SourceEndpoint $PfEndpoint.Identity -SourcePfPrimaryMailboxGuid<guid you noted from previous step> -AutoStart -NotificationEmails<email addresses for migration notifications>

At last, start the Public folder migration to Office 365 by running the following script in Office 365 PowerShell.


Step8: Lock access to the Public folder of the Exchange Server:

Run the following command to lock the existing Exchange Server public folder for users.

Set-OrganizationConfig -PublicFolderMailboxesLockedForNewConnections $true

Step9: Finalize the Public folder migration to Office 365:

At this time, Microsoft suggests ensuring that any email-enabled public folders get synchronized with Office 365.  For this, run the following script:

.\Sync-ModernMailPublicFolders.ps1 -Credential (Get-Credential) -CsvSummaryFile:sync_summary.csv

Now complete the public folders migration to Office 365 by running the following script:


Skip the troublesome manual method, use Shoviv Exchange Server Tool

I’ll not suggest this method for non-technocrats as a single wrong script may corrupt your Public folder. One can use Shoviv Exchange Server Suite to migrate the Public folder to Office 365. It is a simple desktop-based utility. Using this software is the same as using a mobile application, you can monitor everything in a single dashboard. Along with this, the software eliminates the risk of data loss and provides advanced features to enhance users’ experience.

Migrate Public folders to Office 365 without any risk of data loss:

  • Firstly, install and open the software.
  • Then, select Exchange Server Single store.
  • Now provide asked credentials and click Finish.
  • After that, click on the Office 365 option.
  • Select subfolders, and provide asked credentials.
  • Now use the filter option and click next.
  • AT last, the Public folder migration to Office 365 gets started.


Public folder migration to Office 365 is not everyone’s cup of tea. But with the Shoviv Exchange Server Suite, anyone can accomplish it. I have described both methods’ step-by-step process here. Now, it depends on you what you choose to migrate Public folders to Office 365.



About the author

Stuart Clark is working as a technical content writer at Shoviv Software for the last 3 years. In his free time, he loves to write about new technology and read fiction books, his favorite book is "It ends with us" by Coolen Hoover.