Step 1 :
Downloading Required PF migration Scripts
Login to Exchange 2010 –
Download the PF migration Scripts
Step 2:
Backing up PF structure in Exchange 2010
Backing up PF Folder , Items and Permission structure and run a full backup on the PF database.
First Run these Commands to take a Backup of Public Folder structure.
Backing up PF Structure
Get-PublicFolder -Recurse | Export-CliXML C:\PFMigration\Legacy_PFStructure.xml
Backing up PF Folder item Structure
Get-PublicFolderStatistics | Export-CliXML C:\PFMigration\Legacy_PFStatistics.xml
Backing up PF Permission Structure
Get-PublicFolder -Recurse | Get-PublicFolderClientPermission | Select-Object Identity,User -ExpandProperty AccessRights | Export-CliXML C:\PFMigration\Legacy_PFPerms.xml
Step 3:
Removing Unsupported Sign from PF Name in Exchange 2010
Make sure there is no PF folder contains the sign “\” in the name.
Get-PublicFolderStatistics -ResultSize Unlimited | Where {$_.Name -like “*\*”} | Format-List Name, Identity
if it returns any folder , Remove the “\” from the Public Folder name.
NOTE : If the name of a public folder contains a backslash \, the public folders will be created in the parent public folder. Review the .csv file and edit any names that contain the backslash.
Step 4:
Removing any existing Migration Request or any PF Folder in Exchange 2013
Make sure there is no Public folder migration request exist already.
Get-PublicFolderMigrationRequest
If there is any
Remove them
Get-PublicFolderMigrationRequest | Remove-PublicFolderMigrationRequest -Confirm:$false
Make Sure there is no PF mailbox or folder created in Exchange 2013
Get-Mailbox –PublicFolder
Get-PublicFolder
To Remove PF mailbox and PF folder in Exchange 2013
Get-Mailbox -PublicFolder | Where{$_.IsRootPublicFolderMailbox -eq $false} | Remove-Mailbox -PublicFolder -Force -Confirm:$false
Get-Mailbox -PublicFolder | Remove-Mailbox -PublicFolder -Force -Confirm:$false
Step 5:
Making Sure Public Folders is not Locked in Exchange 2010
Make sure PublicFoldersLockedforMigration, PublicFolderMigrationComplete is set to $false
Get-OrganizationConfig | Format-List PublicFoldersLockedforMigration, PublicFolderMigrationComplete

Step 6:
Create the Foldertosize map file in Exchange 2010
Run the Script –
.\Export-PublicFolderStatistics.ps1 Foldertosize.csv mailboxserver.testcareexchange.biz
For Example –
.\Export-PublicFolderStatistics.ps1 Foldertosize.csv exch2010.testcareexchange.biz

Step 7:
Create the public-folder-to-mailbox map file in Exchange 2010
Run the Script –
.\PublicFolderToMailboxMapGenerator.ps1 <Maximum mailbox size in bytes> <Folder to size map path> <Folder to mailbox map path>
For Example – Taking 25 Gb into bytes
.\PublicFolderToMailboxMapGenerator.ps1 26843545600 Foldertosize.csv public-folder-to-mailbox.csv

Step 8:
Determining the number of PF mailboxes required . And Creating it
Now open the public-folder-to-mailbox.csv file , It will show you how many mailboxes you need.

Use the Below Script for 25 mailboxes . my case its only 1
$numberOfMailboxes = 25;
for($index =1 ; $index -le $numberOfMailboxes ; $index++)
{
$PFMailboxName = “Mailbox”+$index;
if($index -eq 1)
{
New-Mailbox -PublicFolder $PFMailboxName -HoldForMigration:$true -IsExcludedFromServingHiearchy:$true;
}
else
{
New-Mailbox -PublicFolder $PFMailboxName -IsExcludedFromServingHierarchy:$true
}
}
Login to Exchange 2013 Server
Creating the PF mailbox “PFMailbox” by using the below command
New-Mailbox -PublicFolder PFMailbox -HoldForMigration:$true

Now Open the public-folder-to-mailbox.csv file and Change to the PFmailbox name which you created.
and copy the CSV file to Exchange 2013 Server root C:\ drive.

Step 9:
Migrating the PF folders
New-PublicFolderMigrationRequest -SourceDatabase (Get-PublicFolderDatabase -Server <Source server name>) -CSVData (Get-Content <Folder to mailbox map path> -Encoding Byte)
==
You can add “ -AcceptLargeDataLoss –BadItemLimit “ Parameters if you encounter corrupted items.
For Example –
New-PublicFolderMigrationRequest -SourceDatabase (Get-PublicFolderDatabase -Server exch2010.testcareexchange.biz) -CSVData (Get-Content C:\public-folder-to-mailbox.csv -Encoding Byte)

To Check the Status of the Migration Request
you can run
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl
On Completion it will show up as “AutoSuspended”
if the data is large its going to take some time 4 –5 GB / hour max .

Step 10:
Lock the public folders to complete the migration for final synchronization (This Step Involves DOWNTIME)
Note : Mail sent to mail-enabled public folders will be queued and won’t be delivered until the public folder migration is complete. (Mails can stay in the queue for up to 48 hours by default)
Login to Exchange 2010 Server
Set-OrganizationConfig –PublicFoldersLockedForMigration:$true

Step 11:
Resuming the Public folder migration to complete successfully .
Set-PublicFolderMigrationRequest -Identity \PublicFolderMigration -PreventCompletion:$falseResume-PublicFolderMigrationRequest -Identity \PublicFolderMigration

Check Status –
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl
If some one is accessing the PF folders or any proxy failures or any live sessions its going to re attempt periodically.

Now it looks completed


Step 11:
Now to Test the PF migration status.
Setting the PF folders on a Test mailbox
Set-Mailbox -Identity test100 -DefaultPublicFolderMailbox PFmailbox

Now add the public folder mailbox

If your PF structure is huge. to confirm everything is ok . Redo Step2 with New .xml file names and you can compare those files before completion.
Step 12:
Exchange 2013 should start serving the Hierarchy
Run
Get-Mailbox -PublicFolder | Set-Mailbox -PublicFolder -IsExcludedFromServingHierarchy $false

Step 13:
On Completion Set PublicFolderMigrationComplete to $true in Exchange 2010 Server.
Set-OrganizationConfig -PublicFolderMigrationComplete:$true
Step 14:
Removing Exchange 2010 Public Folder Database

Now Public Folders have been migrated from Exchange 2010 to Exchange 2013