How to Resolve “New-MailboxExportRequest Error: Header file length is zero”

Exporting mailboxes is a routine job of an Exchange Administrator. When exporting mailboxes with the PowerShell cmdlet, you might encounter some issues. At times, it fails with the below error.

Unable to open PST file ‘EX01\pst_exports\user01.pst’ . Error details: Header file length is zero, is the file is from a previously failed pst export, please delete the file and resume the export.

+ CategoryInfo : NotSpecified: (0:Int32) [New-MailboxExportRequest], RemotePermanentException

+ FullyQualifiedErrorId : 97E980C,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest

After analysing, you might notice that it’s not with all the mailboxes but mostly with large mailboxes, exceeding 1 GB in size. This occurs when you export all the mailboxes to PST, using ForEach PowerShell method. This method is only recommended for small number of mailboxes. If you launching this for large number of mailboxes, it may cause performance issues on the server. So, before running the below command, make sure to check the requirements and storage. The command is as follows:

ForEach ($m in (Get-Mailbox -ResultSize Unlimited)) {New-MailboxExportRequest -Mailbox $m -FilePath “\\EX01\pst_exports\$($m.Alias).pst” }.

The first run will work fine, but when you execute the command for another run, you may get the above error message. If these are failed, you need to remove the failed requests. To see the mailbox export requests on your server, run the command Get-MailboxExportRequest to get all the requests which have been executed on the server. To remove the request, you need to use Remove-MailboxExportRequest PowerShell cmdlet . By itself, the command does need more parameters, but to clean up the server, you need to run the following commands.

To remove all successful requests, you need to use the below given command:

Get-MailboxExportRequest -Status Completed | Remove-MailboxExportRequest

To remove all the failed requests, you need to use the below given command:

Get-MailboxExportRequest -Status Failed | Remove-MailboxExportRequest

Usually, this should fix the problem. Exchange does not remove the export requests automatically. If this still fails, you can look into the detailed report statistics that can be extracted with the command below.

Get-MailboxExportRequest |Get-MailboxExportRequestStatistics –IncludeReport

Another option is to check the Exchange Replication Service, if itis running and functioning well on your Client Access Server (CAS). This test will ensure that the replication service is responding to a remote procedure call (RPC). The below procedure will ensure to test this connectivity.

This test cannot be done through Exchange Management Console (EMC) but must be executed on Client Access Servers with PowerShell. If you have multiple Client Access Servers, you would need to conduct test on all servers, by running the below command.

Get-ClientAccessServer | Test-MRSHealth

To test Exchange Replication Service on a specific Client Access Server, you must run the command below and specify the Identity (name of the server).

Test-MRSHealth –Identity EXC-CAS-001

With the same command, you can get a full report that also include monitoring events, performance counters in the result. The results are exported in XML file format to your location. This will give you a clear indication, if the service is running normally.

Test-MRSHealth -Identity EXC-CAS-001 -MonitoringContext $true | Export-CliXml “C:\Scripts\ExchangeReports\EXC-CAS-001_MRSHealth.xml”

If this would not be the case,, you can first delete the PST files of the failed requests and try the PowerShell cmdlet Get-MailboxExportRequest command again. Although this could be a workaround to the problem, you will end up with more administrative work on your hand while trying to get the one’s that failed and re-run the export request again on those specific mailboxes.
If all this fails, you might want to look at a third party EDB to PST Converter software since the native tools that come with Exchange Server do not offer the solution. Stellar Converter for EDB software can help in such cases. It is the best alternative method to New-MailboxExportRequest PowerShell cmdlet.
The software can be installed on a Windows Server or a Windows 10 machine with minimal effort or complex configuration. It can open any database format or version of Exchange Server from 5.5 to Exchange Server 2019. You can make a granular export to PST and other formats like EML. The application also serves as a migration tool where you can export all or selected mailboxes to a live Exchange Server database or Office 365.