This part will cover how to migrate PF and Removing old Exchange from Active Directory. This can be sometimes tricky and please pay attention what server are You should be on as there is some juggling.
!!! Sometimes will put in Shell examples variables i.e. <FQDN of source server> remember to replace it accordingly to Your environment
1.Migrate Public Folders
1.1 Take a time and check out Technet information about this part that you can find HERE
1.2 Download Migartion Scripts from HERE:
1.3 Prepere migration Files
1.3.1 Copy all the scripts to C:\PFMigration on Exchange 2007
1.3.2 Open Management Shell on Exchange 2007
Create Folder Name to folder size Mapping.
– Export original Public Folder Structure
Get-PublicFolder -Recurse | Export-CliXML C:\PFMigration\Legacy_PFStructure.xml
– Export Public Folder item count size and owners
Get-PublicFolderStatistics | Export-CliXML C:\PFMigration\Legacy_PFStatistics.xml
– Export Public Folder Permission
Get-PublicFolder -Recurse | Get-PublicFolderClientPermission | Select-Object Identity,User -ExpandProperty AccessRights | Export-CliXML C:\PFMigration\Legacy_PFPerms.xml
– If the name of a public folder contains a backslash \, the public folders will be created in the parent public folder when migration occurs. Before you migrate, we recommend that you rename any public folders that have a backslash in the name.
Get-PublicFolderDatabase | ForEach {Get-PublicFolderStatistics -Server $_.Server | Where {$_.Name -like „*\*”}}
* If You are using this Guide for Exchange 2010 to Exchange 2013 Migration check appropriate script in Technet (Step2 Point 2a)
– If any public folders are returned, you can rename them by running the following command
Set-PublicFolder -Identity <public folder identity> -Name <new public folder name>
– Make sure there isn’t a previous record of a successful migration (Command Should Return False in both fields)
Get-OrganizationConfig | Format-List PublicFoldersLockedforMigration, PublicFolderMigrationComplete
1.3.3 Still on Exchange 2007 machine
– Create the folder name-to-folder size mapping file.
.\Export-PublicFolderStatistics.ps1 PF_Statistic.csv <FQDN of source server>
1.3.4 Long on to Exchange 2013 Management Console
– Copy PF_Statistic.csv form Exchange 2007 Machine to Exchange 2013 C:\PFMigration and go in management Shell to this folder.
.\PublicFolderToMailboxMapGenerator.ps1 5GB PF_Statistic.csv PF_Folder2Mailbox.csv
*Max Size is 25GB

1.3.5 Create mailboxes to store Public Folders on Exchange 2013 Shell
TIP: I prefer to store Public Folders in separate Mailbox Database and name Public Folders Mailboxes respectfully to its content. So If you like to set it up like me just create new Mailbox Database (e.g. PF_Database) and rename Mailbox name in PF_Folder2Mailbox.csv and new-mailbox command (e.g. PF_Mailbox1) For purpose of this guide I will left names as created by Microsoft Provided scripts.
New-Mailbox -PublicFolder Mailbox1 –HoldForMigration: $true
You can specific name and mailbox database by adding –Database <Mailbox Database Name> and –Server <FQDN of source server>
1.3.5 Now start Migration – remember to be aware on witch server you are and also that Public Folders will now be unavailable for users.
Exchange 2013 Shell
– Start Migration request
New-PublicFolderMigrationRequest -SourceDatabase (Get-PublicFolderDatabase -Server <FQDN of source server>) -CSVData (Get-Content PF_Folder2Mailbox.csv -Encoding Byte)
– Check Migration State
Full
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl
Brief
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl | Select Name,Status
If State is AutoSuspended do the fallwoing
Exchange 2007 Shell
Lock Folders for Migration
Set-OrganizationConfig -PublicFoldersLockedForMigration:$true
Exchange 2013 Shell
Resume Migration Task
Set-PublicFolderMigrationRequest -Identity \PublicFolderMigration -PreventCompletion:$false
Resume-PublicFolderMigrationRequest \PublicFolderMigration
– Check Migration State
Full
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl
Brief
Get-PublicFolderMigrationRequest | Get-PublicFolderMigrationRequestStatistics -IncludeReport | fl | Select Name,Status
Now be patient State should change to InProgress and wait till You see state as completed.
1.3.6 Test and Unlock the Public Folder
Assign new Public Folder Mailbox to test user
Set-Mailbox -Identity <Test User Mailbox> -DefaultPublicFolderMailbox mailbox1
Logon to test user mailbox via OWA or Outlook and test folders. See if you can manage it and create items.
If everything is OK proceed
Exchange 2013 Shell
Get-Mailbox -PublicFolder | Set-Mailbox -PublicFolder -IsExcludedFromServingHierarchy $false
Exchange 2007 Shell
Set-OrganizationConfig -PublicFolderMigrationComplete:$true
2. Remove Exchange 2007 – Everything is now done on Exchange 2007 Shell and UI
This task should be simple. Delete and uninstall everything J
2.1 Check if all mailbox are migrated to new server and if so Delete all the Mailbox Database form Exchange 2007
Remove-MailboxDatabase -Identity <Mailbox Database Name>
2.2 Remove all OAB form Exchange 2007. Check if OAB form new server is assign.
Remove-OfflineAddressBook -Identity <OAB Name>
2.3 Uninstall Exchange 2007 form server. From Elevated Command Prompt run
Setup.com /mode:uninstall
Now it is done you can remove old server form domain. I hope this was helpful for some of You.
Cheers.
Maciek Jędryszek