Resolved Error: remove-mailboxexportrequest value cannot be null

Microsoft release Cumulative updates every month/quarter for Exchange and while these updates provide fixes from previous cumulative updates (CU), they also introduce new errors or bugs.

Take note before we move on, each cumulative update (CU) they release is a full version of Exchange. So, for example if you have Exchange 2013 CU20 and you install CU21 or you have Exchange 2016 CU12 and you install CU13, it is a full version. If you are installing a brand-new server to add to your set of servers then you don’t need to go through each CU individually but can download the latest one.

Back to the errors or bugs. In this example we will look at a bug that was introduced in Exchange 2016 CU6.

When you export mailboxes in Exchange, the export requests stay once it has completed. You need to go and manually remove the export requests in Exchange. Now to do this, you would need to run the following command from the Exchange Management Shell (EMS):

  • Get-MailboxExportRequest | Remove-MailboxExportRequest

The above command is supposed to ask you to confirm the removal and proceed to remove all the export requests, however you encounter this error:

“Value cannot be null…”

As this command should work, you could ask your TAM to log it with Microsoft and see what they say or you can log a call with Microsoft and if the Cumulative update at the time is the latest they will check and then get back to you with an answer.

Generally you would need to wait until the next Cumulative Update (CU) is released as it should address the issue experienced above.

There is a workaround in place for those companies that are still on older versions of Exchange 2016 or have CU6 in place and are not planning on upgrading or just have not gotten round to upgrading to the latest version.

You can run the command below to remove the mailbox export requests:

  • Get-MailboxExportRequest -Status Completed | %{Remove-MailboxExportRequest $_.RequestGuid -Confirm:$false}

If the above command still does not work, you can look at using ADSIEdit to remove the requests.

Now I want to caution you on this. Fiddling in ADSIEdit can lead to you deleting or changing the wrong information and causing the systems to crash or not exist anymore depending on what you delete or change. You can bring an organization down very quickly so exercise caution when using ADSIEdit to remove information.

To find this mailbox export requests, you need to launch ADSIEdit and perform the following:

  • Connect to a domain controller and select Configuration.
  • Expand CN=Configuration.
  • Expand CN=Services
  • Expand CN=Microsoft Exchange
  • Expand the name of your site. E.G. CN=Test
  • Locate CN=Mailbox Replication
  • Expand CN=Mailbox Replication
  • Click on CN=MailboxExportRequests

On the rights hand after you clicked on CN=MailboxExportRequests, you will see all the requests.

Select all of them or right click each one and select delete.

Give Exchange/AD replication a few minutes and when you run the command below to check the mailbox export requests, they should all be gone.

  • Get-MailboxExportRequest

So as mentioned, please be careful when playing around in ADSIEdit.

In Cumulative Update (CU) CU8 for Exchange 2016, Microsoft fixed the issue above and the normal command to remove mailbox export requests works again, the command in question is as below:

  • Get-MailboxExportRequest | Remove-MailboxExportRequest

Let’s take a look at another scenario.

You are running a later version than CU8 for Exchange 2016 but you get the same error.

However in this case you are connecting remotely to your Exchange Server using Remote Exchange PowerShell commands.

So how do you connect remotely to Exchange? Well, you could have used the following commands from PowerShell:

$cred = Get-Credential

Enter-PSSession -ComputerName Server1-Credential $cred

[Server1] Add-PSSnapin Microsoft.Exchange.Management.PowerShell.E2010

You are now connected to Server1 and can run commands but it fails with the error above: “ Value cannot be null”

You need to now update your commands and use the following to connect to your Exchange Server:

$cred = Get-Credential

$Session = New-PSSession -ConfigurationName Microsoft.Exchange -ConnectionUri http://<FQDN of Exchange Server>/PowerShell/ -Credential $cred -Authentication Kerberos

Import-PSSession $Session

As you can see, both commands ask for your credentials however in the second one, you are creating a new session by specifying the URI of Exchange PowerShell virtual directory and then finally importing the session.

Now when you run the command to remove the mailbox export requests it should go through without error.

Cmdlet

Role

New-MailboxExportRequest

Export mailbox to a .pst file.

Get-MailboxExportRequest

detailed status of an ongoing export requests 

Get-MailboxExportRequestStatistics

View detailed information about export requests.

Set-MailboxExportRequest

Change export request options

Suspend-MailboxExportRequest

Suspend an export request

Resume-MailboxExportRequest

Resume an export request  

Remove-MailboxExportRequest

Remove export requests.