Decommission public folders in Exchange Online

Exchange Online users can access public folders homed in Exchange Online or Exchange Server (on-premises). There may be scenarios where you want to decommission public folder access for all Exchange Online users. The steps here apply to scenarios where EXO users are accessing public folders deployed locally in Exchange Online or public folders remotely deployed at on-premises servers.

Note

In case you want to partially remove public folder access for selected Exchange Online users who use Outlook for Windows desktop, check this article.

Note

If you want to remove public folder deployment from Exchange on-premises, check this article.

Pre-requisites

Before you proceed, ensure that:

  • Exchange Online users no longer need public folder data.
  • If you're using Microsoft Entra Connect (formerly known as AAD connect) to synchronize your on-premises directory with Microsoft Entra (AAD), you need to perform the following steps (if you aren't using Microsoft Entra Connect, you can skip these steps):
    • Log in to the on-premises computer that has Entra Connect tool installed, open Microsoft Entra Connect, and then select Configure.
    • On the Additional tasks screen, select Customize synchronization options, and then select Next.
    • On the Connect to Microsoft Entra ID screen, enter the appropriate credentials, and then select Next. Once connected, keep clicking Next until you're on the Optional Features screen.
    • Make sure that Exchange Mail Public Folders isn't selected. If it isn't selected, you can continue to the next section. If it's selected, click to clear the check box, and then select Next.

      Note

      If you don't see Exchange Mail Public Folders as an option on the Optional Features screen, you can exit Microsoft Entra Connect and proceed to the next section.

    • After you have cleared the Exchange Mail Public Folders selection, keep clicking Next until you're on the Ready to configure screen, and then select Configure.

After completing the above steps, you need to configure your tenant to remove public folders. All the following steps must be performed from Exchange Online PowerShell with an account that is assigned to the Organization Management role group.

Disable public folder access on users

Use the following command to determine current public folder deployment state at the organization level:

Get-OrganizationConfig | fl PublicFoldersEnabled,RemotePublicFolderMailboxes

Optional: If PublicFoldersEnabled is Remote with RemotePublicFolderMailboxes populated, it indicates that the public folders are deployed and active on-premises. In case you want to remove the on-premises public folder deployment, follow the steps here.

Next, use the following command to update public folder deployment state at tenant level:

Set-OrganizationConfig -PublicFoldersEnabled None -RemotePublicFolderMailboxes:$null

Next, use the following command to remove any admin-assigned public folder mailbox on the users:

Get-Mailbox -ResultSize unlimited | where {$_.DefaultPublicFolderMailbox -ne $Null} | Set-Mailbox -DefaultPublicFolderMailbox $Null

Next, use the following command to ensure there's no public folder mailbox assignment present on the users:

Get-Mailbox -ResultSize unlimited | where {$_.DefaultPublicFolderMailbox -ne $Null -OR $_.EffectivePublicFolderMailbox -ne $Null}

Check for and remove mail enabled public folders

Step 1: Check for the presence of Mail Enabled Public Folders (MEPFs)

Run the following command to see if MEPFs are present:

Get-MailPublicFolder

If the command returns no output, go to Step 2. But, if MEPFs are present and listed in the above command, perform the following step to back up the MEPF details.

Optional: Back up the MEPF details

MEPFs don't hold any data themselves, but are objects in Active Directory that are linked to public folder that hosts the actual data.

Run the following command to take backup of MEPF properties:

Get-MailPublicFolder -ResultSize Unlimited| Export-Clixml MEPF.XML

Step 2: Disable MEPFs

Run the following command to remove the MEPFs:

Get-MailPublicFolder -ResultSize Unlimited | Disable-MailPublicFolder

Now, run the Get-MailPublicFolder command again and ensure no MEPFs are listed.

Check for and remove public folder mailboxes

To check for the presence of public folder mailboxes, run the following:

Get-Mailbox -PublicFolder

If the above command returns no output, go to the next step Disable public folder access on users.

If public folder mailboxes are present and listed after running the above command, use the following commands to remove the public folder (PF) mailboxes:

Note

If there are any legacy or in-place holds on public folder mailboxes, clear them before proceeding to the next step. Check this article for detailed steps.

$hierarchyMailboxGuid = $(Get-OrganizationConfig).RootPublicFolderMailbox.HierarchyMailboxGuid

Get-Mailbox -PublicFolder | Where-Object {$\_.ExchangeGuid -ne $hierarchyMailboxGuid} | Remove-Mailbox -PublicFolder -Confirm:$false -Force

Get-Mailbox -PublicFolder | Where-Object {$\_.ExchangeGuid -eq $hierarchyMailboxGuid} | Remove-Mailbox -PublicFolder -Confirm:$false -Force

Note

The deleted public folder mailboxes can be recovered until the retention period is over. After the retention period is over, the public folder mailboxes will be permanently deleted. Check this article for restoring public folder mailboxes.