Public Folders in Microsoft Exchange are a feature that allows users to store and share information with others in their organization. They are typically used for collaboration and archiving purposes, providing a centralized location for users to access and manage shared content such as documents, calendars, contacts, and email messages.
Like an Exchange mailbox, you can export Public folders to PST, and we will discuss how to do it in this tutorial.
Requirements
- Access to an Exchange organization. This tutorial will be using Exchange Online but should also work with Exchange Server 2016 and Exchange Server 2019.
- A Windows computer with Outlook 2016 or later.
- Existing public folders are accessible in your Outlook client.
Listing Public Folders and User Permissions
Knowing which public folder to export is one part of exporting Exchange public folders to PST. Another is ensuring the user who will export the public folder can access it.
From the user’s perspective, they have access to the public folder if they can access it in Outlook. But for administrators, it is crucial to know how to list public folders and user permissions.
Public folders are contained inside public folder mailboxes. There can be many public folder mailboxes and also many public folders in each.
Using the Exchange Admin Center, you can view the public folder mailboxes:

And public folders.

Run these commands in PowerShell to list all public folder mailboxes and public folders.
Get-Mailbox -PublicFolder -ResultSize Unlimited Get-PublicFolder -Recurse -ResultSize Unlimited | Select-Object Name, ParentPath, MailboxOwnerId

To get public folder permissions, the command you want is Get-PublicFolderClientPermission. To list permissions for one public folder, run this command:
Get-PublicFolderClientPermission -Identity <Public Folder>
For example, to get the UK London Sales permissions:
Get-PublicFolderClientPermission -Identity '\UK London Sales'

But if you want to get the permissions for all public folders, you do so like this:
Get-PublicFolder -Recurse -ResultSize Unlimited | Get-PublicFolderClientPermission

Important Limitations of the Outlook COM Export Method
Keep in mind that this export method relies on Outlook COM automation:
New-Object -ComObject Outlook.Application
Because of this, during the export process, you will require:
- Microsoft Outlook installed on the machine;
- an interactive user session;
- a configured Outlook profile with access to the public folders.
Note that this method is not a good option for:
- server-side automation;
- scheduled background tasks;
- CI/CD pipelines;
- non-interactive PowerShell sessions.
Keep in mind that in many cases, Outlook COM automation may behave unpredictably on Windows Server systems or disconnected RDP sessions (this is happening because Outlook was originally designed as a desktop app).
For large-scale/enterprise exports, we recommend you to use compliance/eDiscovery export tools or mailbox-based export methods (instead of Outlook COM automation).
Note. This method exports public folder content through the Outlook MAPI client and not directly from Exchange databases/Exchange Online.
Alternative Methods to Export Exchange Public Folders
Depending on your Exchange environment and compliance requirements, Outlook COM automation may not always be the best option for exporting public folder content. In enterprise environments, you should prefer server-side/compliance-oriented export methods.
| Method | Supported Environment | Notes |
|---|---|---|
| Outlook COM + PST | Exchange Online/On-Prem | Simple but requires Outlook and interactive session |
| Microsoft Purview Content Search | Exchange Online | Recommended for compliance/eDiscovery exports |
| eDiscovery Export Tool | Exchange Online | Supports large-scale search and PST export |
| New-MailboxExportRequest | Exchange Server On-Premises | Native server-side PST export for mailboxes |
Keep in mind that the New-MailboxExportRequest cmdlet cannot export modern Exchange public folders directly because public folders are not regular user mailboxes. This cmdlet is mainly used for mailbox PST exports in Exchange Server on-premises environments.
Tip. Although modern Unicode PST files support sizes up to 50 GB by default (and can be increased), very large PST files may reduce Outlook performance and increase the risk of corruption. For large public folders, you should consider exporting into multiple smaller PST files where practical.
Using Microsoft Purview Content Search for Exchange Online
For Microsoft 365 and Exchange Online environments, we recommend you to use Microsoft Purview Content Search and eDiscovery tools (for large-scale exports and compliance-related tasks).
This approach will provide you with:
- server-side export;
- better scalability;
- audit logging;
- compliance search capabilities;
- reliable PST export for legal and archival purposes.
Note that unlike Outlook COM automation, Content Search exports do not require Outlook installed on a workstation.
The instructions above assume you already have an Exchange PowerShell session open, whether Online or On-Premises.
Export Public Folder to PST using PowerShell
You can export public folders to PST using PowerShell, especially when you want to automate the process. This automation can be achieved using Microsoft.Office.Interop.Outlook Namespace.
Copy the code below and save it as Export-PublicFolder.ps1. You can also download this script from this Gist.
[CmdletBinding()]
param (
[Parameter(Mandatory)]
[string]
$PublicFolderPath,
[Parameter(Mandatory)]
[string]
$PstFilePath
)
## Initialize the Outlook COM Object
$Outlook = New-Object -ComObject Outlook.Application
## Compose the top public folder path <Public Folders - ACCOUNT_NAME\All Public Folders>
$pfTopFolder = $Outlook.Session.Folders | Where-Object { $_.Name -like "Public Folders -*" }
## Append the specified $PublicFolderPath
$PublicFolderPath = (($pfTopFolder.Name) + '\All Public Folders\' + $PublicFolderPath)
Write-Verbose "Public Folder Parent = $PublicFolderPath"
## Split the folder path into levels
$pfPath = $PublicFolderPath.Split('\')
## Initialize the public folder object to export.
$PublicFolderToExport = $Outlook.Session.Folders.Item($pfPath[0]).Folders.Item($pfPath[1])
## Append each public folder level
for ($i = 2; $i -lt ($pfPath.count); $i++) {
try {
$PublicFolderToExport = $PublicFolderToExport.Folders.Item($pfPath[$i])
}
catch {
## If the folder name does not exist, terminate the script.
"The public folder path [$($PublicFolderPath)] does not exist." | Out-Default
return $null
}
}
Write-Verbose $($PublicFolderToExport.FullFolderPath)
## Create the PST export folder if it doesn't exist.
$pstFolder = Split-Path $PstFilePath -Parent
if (!(Test-Path $pstFolder)) {
try {
$null = New-Item -Type Directory -Path $pstFolder -ErrorAction Stop
Write-Verbose "Output folder [$pstFolder] created."
}
catch {
Write-Error "Failed to create the folder [$pstFolder]."
Write-Error $_.Exception.Message
return $null
}
}
## Initialize the PST store
$namespace = $Outlook.GetNameSpace("MAPI")
## Attach the PST to the Outlook session
$namespace.AddStore($PstFilePath)
$pstOutlookStore = $namespace.Session.Folders.GetLast()
Write-Verbose "PST [$PstFilePath] attached as [$($pstOutlookStore.Name)]."
## Start export.
Write-Verbose "Start public folder export to [$PstFilePath]."
[void]$PublicFolderToExport.CopyTo($pstOutlookStore)
Write-Verbose "Start public folder export is finished."
## Detach PST from Outlook
$namespace.RemoveStore($pstOutlookStore)
Write-Verbose "PST [$PstFilePath] detached."
$outlook.Application.quit() Once you’ve saved the script, run it in PowerShell like so:
.\Export-PublicFolder.ps1 `
-PublicFolderPath 'UK Liverpool Sales' `
-PstFilePath C:\PublicFolderExport\uk_liverpool_sales.pst `
-Verbose
- -PublicFolderPath — This parameter accepts the public folder path relative to the ‘All Public Folders’ level. For example, ‘UK Liverpool Sales’ translates to “Public Folders – <ACCOUNT>\All Public Folders\UK Liverpool Sales’
- Suppose the UK Liverpool Sales public folder has a subfolder called Comp&Ben; then you can specify it as -PublicFolderPath ‘UK Liverpool Sales\Comp&Ben’.
- -PstFilePath — This parameter specifies the output PST file. If that path doesn’t exist, the script will create it. If the folder cannot be created, the script will terminate.

Now check if the PST file has been created successfully before starting the export:
Test-Path $PstFilePath
Note that this script is intentionally simplified for demonstration purposes. In production environments, you should extend it with recursive folder export support, logging, detailed error handling, and progress reporting.
Possible Improvements for the Export Script
The example above demonstrates the basic approach for exporting Exchange public folders to PST using Outlook COM automation. However, in production environments, you can extend this script with additional reliability and automation features.
Exporting Public Folder Subfolders Recursively
The script we mentioned above exports only a single public folder level. In enterprise environments, public folders often contain multiple nested subfolders that should also be exported automatically. You can improve the script by recursively enumerating child folders using the Folders collection and exporting each subfolder into the PST structure.
This can be especially useful for:
- large departmental public folders;
- archive hierarchies;
- multi-level collaboration folders.
Here is an example of recursion:
function Export-FolderRecursive {
param ($Folder, $PstStore)
[void]$Folder.CopyTo($PstStore)
foreach ($subFolder in $Folder.Folders) {
Export-FolderRecursive -Folder $subFolder -PstStore $PstStore
}
}
Add Logging for Export Operations
For better troubleshooting and auditing, you should consider adding logging support to the script. For example, you can log:
- export start/end time;
- processed public folders;
- failed exports;
- PST file paths;
- permission-related errors.
You can use a simple approach like the following:
Start-Transcript
Stop-Transcript
or you can write custom log entries using:
Add-Content
Add Error Handling per Public Folder
Currently, a single export failure may terminate the entire script execution.
In larger environments, we recommend you to wrap each folder export operation inside separate try/catch blocks so that one problematic public folder does not stop the entire export process.
Note that this is extremely important when:
- permissions differ between folders;
- corrupted items exist;
- large folders timeout during export.
Adding a Progress Indicator
When you exporting large public folders, the process may run for a long time without visible activity. You can improve the user experience by adding progress indicators with:
Write-Progress
This helps you to monitor:
- currently processed folder;
- overall export progress;
- long-running export operations.
Troubleshooting Common Public Folder Export Errors
Outlook not found / COM object creation failed
In case the script returns errors similar to:
New-Object : Cannot create COM object Outlook.Application
or:
Retrieving the COM class factory for component failed
this usually means that Microsoft Outlook is not installed on the machine or Outlook has not been launched/configured at least once for the current user profile.
In order to fix this problem, follow the next steps:
- Install Outlook 2016 or later;
- Create and config an Outlook profile;
- Launch Outlook once interactively;
- Run the PowerShell console under the same user profile.
MAPI errors
Some environments may return MAPI-related errors when exporting large public folders/when Outlook cached mode is corrupted.
Common examples include:
- MAPI_E_NOT_FOUND
- MAPI_E_FAILONEPROVIDER
- Cannot expand the folder
In order to resolve these problems, you should:
- Restart Outlook and PowerShell;
- Recreate the Outlook profile;
- Ensure the public folder is fully visible in Outlook;
- Disable Cached Exchange Mode temporarily;
- Verify if Outlook can open the public folder manually before running the script.
PST file locked
In case the PST file is already mounted in Outlook or opened by another process, the export may fail with access or file lock errors.
For example:
The process cannot access the file because it is being used by another process.
In order to fix this problem:
- Close Outlook completely;
- Ensure the PST file is not already attached;
- Use a different PST filename;
- Check antivirus software that may lock PST files during scanning.
Permission denied
In case the export completes with access denied errors/empty PST files, verify if the user has sufficient permissions on the public folder. You can do that by using the command:
Get-PublicFolderClientPermission -Identity '\PublicFolderName'
Note that at minimum, the exporting user should have Reviewer/higher permissions to the target public folder.
Wrapping up
Exporting public folders to PST files is more or less a manual process. Using Outlook to export public folder content is convenient but can be cumbersome when exporting multiple public folders.
But with some PowerShell scripting strategy, it can be automated with consistent and repeatable results. Good luck!

Hello Cyril Kardashevsky
Server Details:
Windows 2008R2
Exchange 2010
Client Details:
Windows 10
Office 365 Apps
Error Description:
Error appears from line 50 – 52
I am trying to run this script directly from a domain joined Windows 10 client with Office365 Apps (32bit). Unfortunately it does not work. I have adjusted the path to C:BackupPublic Folders but that didn’t help either.
Can you possibly comment exactly the parts of the script to customize this way with the needed content?
Thanks for feedback
Hi,
I’m getting the same errors, any luck fixing this anybody?
Hi Cyril, could you expand on how you are constructing the variable: $PublicFolderToExport = $Outlook.Session.Folders.Item(‘Public Folders – Helpdesk’)…..
what are the elements level-1, level-2 etc… I’m trying to translate this to my environment where I have a structure:
\All Public Folders
\TestFolder1
If I merely substitute your value of ‘Public Folders – Helpdesk’ with ‘TestFolder1’ I get an error… so I’d like to understand how that folder path is being constructd & passed to the function…
Many thanks!
Hi June,
I am getting following error while I executing the script.
The attempted operation failed. An object could not be found.
At line:25 char:1
Write-Verbose : Cannot bind argument to parameter ‘Message’ because it is null.
At line:39 char:15
You cannot call a method on a null-valued expression.
The error indicates that the Public Folder Path you specified to the script is not found or there was no match. Ensure the public folder path does not include the “Public Folders – \All Public Folders\” part and should be specified in the script as it is written in Outlook.
Dear
Thanks for the script. It’s working for me.
However, the script exports the folder I specify, but also all sub folders and their items.
How can I avoid that sub folders and their items are exported too?
I just want to export specific public folders in the middle of the PF name space.
Thanks for the feedback.
Regards
Peter