Jaa


Remove public folder deployment from Exchange Server 2013 or later

After you've migrated all the on-premises users and public folders to Exchange Online, you need to remove the on-premises public folders deployment. Performing a clean removal of the on-premises public folder deployment is critical as an improper removal can lead to issues like orphaned Mail Enabled Public Folders (MEPFs) and blocked SMTP addresses in Microsoft Entra ID or Exchange Online.

This article lists the steps to safely remove public folders and related data from an on-premises deployment of Exchange Server 2013 or later versions.

Prerequisites

Before you begin, make sure that:

  • You've migrated the on-premises public folders to Exchange Online.

  • There are no users on-premises or in Exchange Online that are connecting to or using public folders deployed on-premises.

  • On-premises public folder mailboxes are backed up before removal.

  • All the following steps must be performed from Exchange Management Shell with the admin account that has necessary roles assigned.

Disable public folder access on users

  1. Run the following command to disable system public folder mailbox assignment on the users:

    Set-OrganizationConfig -PublicFoldersEnabled None
    
  2. Then, run the following command to remove any admin-assigned public folder mailbox on the users:

    Set-ADServerSettings -ViewEntireForest:$true
    Get-Mailbox -ResultSize unlimited | where {$_.DefaultPublicFolderMailbox -ne $Null} | Set-Mailbox -DefaultPublicFolderMailbox $Null 
    
  3. Allow up to an hour for AD replication and the changes to take effect. Then, run the following command to ensure there's no public folder mailbox assignment present on the users:

    Set-ADServerSettings -ViewEntireForest:$true
    Get-Mailbox -ResultSize unlimited |?{$_.DefaultPublicFolderMailbox -ne $Null -OR $_.EffectivePublicFolderMailbox -ne $Null}
    

Clean-up mail enabled public folders

Use the Exchange Management Shell to run the PowerShell commands listed in these steps.

  1. Back up the MEPF details. Mail Enabled Public folders don't hold any data themselves but are objects in Active Directory that are linked to public folder that hosts the actual data. Run:

Set-ADServerSettings -ViewEntireForest:$true 
Get-MailPublicFolder -ResultSize Unlimited| Export-Clixml MEPF.XML
 
  1. Disable MEPFs.

Run the following command:

Set-ADServerSettings -ViewEntireForest:$true 
Get-MailPublicFolder -ResultSize Unlimited | Disable-MailPublicFolder 

  1. Verify that no MEPFs are listed. You also might verify that there's no more object of type "PublicFolder" in any of the Microsoft Exchange System Objects OUs in your on-premises AD.

Run:

Get-MailPublicFolder

  1. Verify the Exchange Mail Public Folders checkbox is cleared from the Microsoft Entra Connect tool.

mail public folders

  1. Perform the Microsoft Entra Connect Sync.

Remove the public folder mailboxes

The following command locks the public folders for user connections and indicates public folder migration has been completed in the environment:

Set-OrganizationConfig -PublicFolderMailboxesLockedForNewConnections $true -PublicFolderMailboxesMigrationComplete $true 

  1. Remove secondary hierarchy PF mailboxes.
Set-ADServerSettings -ViewEntireForest:$true 

Get-Mailbox -PublicFolder -ResultSize Unlimited |?{$_.IsRootPublicFolderMailbox -ne "True"} | Remove-Mailbox -PublicFolder 

  1. Remove the primary hierarchy PF mailbox:

Get-Mailbox -PublicFolder |?{$_.IsRootPublicFolderMailbox -eq "True"} | Remove-Mailbox -PublicFolder