Latest News

PowerShell Command to Export Public Folder to PST in Exchange 2019/2016/2013/2010

Market Trends

Users can use PowerShell for an effective transfer of public folders to PST efficiently

Public folders are special mailboxes in on-premises Exchange Server used to share information among users or people in a workgroup or organization. The public folder provides a common space for the users to collect, organize, and share documents or information and facilitate collaboration.

Users having access to public folders can see the content stored in them by other users and vice-versa. One can access the Public Folder from Outlook for Mac, Outlook for Windows, and Outlook Web App (OWA).

When added to the member of a distribution group, public folders can also be used for archiving emails sent from mail-enabled public folders. When an email is sent to the group, a copy of the email is automatically saved to the public folder.

In an on-premises Exchange Server, there are mainly two types of public folder mailboxes.

  • Primary Hierarchy Mailbox

Primary Hierarchy Mailbox or Public Folder Master Hierarchy Mailbox is the first public folder created in the Exchange Server. Also, this is the only writable copy of the public folder hierarchy.

  • Secondary Hierarchy Mailbox

All public folder mailboxes created after the primary hierarchy mailbox are called Secondary Hierarchy Mailboxes. These public folder mailboxes are read-only copies of the hierarchy. Therefore, any changes in the public folder hierarchy redirect to Primary Hierarchy Mailbox and replicate to other Public Folder mailboxes to avoid conflicts.

In this article, you will learn the process to export public folders to PST format in Exchange Server 2010, 2013, 2016, and 2019 by using PowerShell command. In addition, we have also mentioned an advanced solution to quickly export all public folders to PST, Office 365, or another live Exchange Server directly.

How to Export Public Folders to PST in Exchange Server?

To export user mailboxes to PST, you can use New-MailboxExportRequest PowerShell cmdlet in Exchange Server 2010 SP1 or later versions. However, there is no PowerShell cmdlet to export public folders to PST in Exchange Server 2010, 2013, 2016, or 2019.

If you need to export public folders to PST via PowerShell, you need to create a PowerShell script that uses Outlook application COM object to extract public folders to PST format. You can also use Outlook Import/Export wizard to export public folders to PST format.

If there are multiple public folders to export, the user account should have access to all those public folders. Also, you need to select and export them to PST format manually. In a nutshell, the Outlook application is required on a Windows PC or your Exchange Server to export public folders to PST format.

Alternatively, you can use an EDB to PST converter software, such as Stellar Converter for EDB, to overcome the limitations of the manual method and PowerShell script. The software helps you extract and export all public folders at once from your Exchange Server database (EDB) to PST format in a few clicks. You can also use the software to directly export the public folders to Office 365 or live Exchange Server.

Steps to Use PowerShell to Export Public Folders to PST

To create a PowerShell script to export public folders to PST, open Notepad and paste the following code.

function Export-MailboxFolder($folder)

{

Begin{

$Outlook = New-Object -ComObject Outlook.Application

$namespace = $Outlook.GetNameSpace("MAPI")

}

Process{

New-Item -Path 'C:\PFBackup\PublicFolders' -Name "$($folder.Name)" -ItemType Directory

foreach ($f in $folder.folders) {

$PSTPath = 'C:\PFBackup\PublicFolders' + '\' + "$($folder.Name)"

$PSTName = $($f.name) + '.pst'

$FullPST = $PSTPath + '\' + $PSTName

$namespace.AddStore("$FullPST")

$pstFolder = $namespace.Session.Folders.GetLast()

[void]$f.CopyTo($pstFolder)

}

}

End{

"Remove attached PST in Outlook"

$RemPST = $Outlook.Session.Stores | Where DisplayName -EQ 'Outlook Data File'

foreach ($pst in $RemPST){

$Outlook.Session.RemoveStore($pst.GetRootFolder())

}

}

}

$PublicFolderToExport = $Outlook.Session.Folders.Item('Public Folders – Helpdesk').folders.item('All Public Folders').Folders.Item('Level-1').folders.item('Level-2').folders.item('Level-3')

Export-MailboxFolder $PublicFolderToExport

Note: Change C:\PFBackup\PublicFolders (highlighted in code) with your desired folder location to save the exported public folder files as PST.

  • Press CTRL + S or go to File > Save and then choose a location where you want to save the PowerShell script.
  • From the dropdown, choose All Files and enter ps1 as the script name.
  • Close Notepad and go to the location where you've saved the ps1 script.
  • Right-click on the script and choose Run with PowerShell.
  • If prompted, type Y and hit Enter to confirm and run the script.
  • Wait for a while and then check the folder for exported public folders as PST files.

Note: Ensure Outlook is installed and configured with the user or administrator account having access to the public folders you want to export to PST.

Conclusion

In Exchange 2019, 2016, 2013, and 2010, there's no PowerShell cmdlet to export public folders from the Exchange mailbox database to PST format. If you need to export the public folders to PST, you can use the Outlook Import Export wizard or a PowerShell script that we mentioned in this article. It's just that you need to repeat all the steps multiple times until you export all your public folders. Moreover, there's no control over what mail items you want to export from public folders. To avoid such a scenario, use an EDB to PST converter software to export all your mailboxes to PST, Office 365, or live Exchange with complete peace of mind.

Join our WhatsApp Channel to get the latest news, exclusives and videos on WhatsApp

                                                                                                       _____________                                             

Disclaimer: Analytics Insight does not provide financial advice or guidance. Also note that the cryptocurrencies mentioned/listed on the website could potentially be scams, i.e. designed to induce you to invest financial resources that may be lost forever and not be recoverable once investments are made. You are responsible for conducting your own research (DYOR) before making any investments. Read more here.

BlockDAG's $150M Surge Steals the Spotlight as Pepe Unchained’s Presale Winds Down — What Are Traders Saying?

Top 6 Best Cryptos to Buy Now for Massive Gains – The Ultimate Crypto List for 2025

Bitcoin ETFs Surge as Crypto Market Boom; BlockDAG Raises $150M in Record Time

Don’t Buy at 10x Higher Prices in January: Expert Says Last Chance to Get In Cardano and DTX Before Moonshot

BlockDAG Presale’s $20M Jump in 48Hrs or Rexas Finance’s $8.6M Goal: Which One Steals the Spotlight?