How do I know if an Exchange mailbox has an archive?

Posted on 2016-08-17
Medium Priority
Last Modified: 2016-08-18
I am writing a PowerShell Script for Exchange 2013 to export all mailboxes and archives to a PST.  When there is an archive the script works with no issues, however when there is none I get the message below:

Mailbox 'Alex Simmons' has no archive. + CategoryInfo          : InvalidArgument: (True:SwitchParameter) [New-MailboxExportRequest], MailboxLacksArchivePermanentException + FullyQualifiedErrorId : DCF7E01A,Microsoft.Exchange.Management.RecipientTasks.NewMailboxExportRequest + PSComputerName        : 2013-exchange.contoso.com

Does anyone have any input on how I can determine if there is an archive.  Below I have the PowerShell script that I am trying to run.  I would think there is some type of ‘if’ command that would say, if(mailbox == IsArhcive) extract it.

#Iterate through each mailbox on the current Exchange server.
foreach ($mailBoxName in (Get-Mailbox)){
	#Start export of current mailbox.
	New-MailboxExportRequest -Mailbox $mailBoxName.Alias -FilePath "${uncOutputDirectoryString}$($mailBoxName.Alias).pst"

	#Wait for the export to complete.
	while(!(Get-MailboxExportRequest -Mailbox $mailBoxName.Alias -Status Completed))
		Start-Sleep -s 300
	#Export Archive
	#ToDo: How do i determine if there is an archive?
	New-MailboxExportRequest -Mailbox $mailBoxName.Alias -IsArchive -FilePath "${uncOutputDirectoryString}$($mailBoxName.Alias).IsArchive.pst"

	#Wait for the export to complete.
	while(!(Get-MailboxExportRequest -Mailbox $mailBoxName.Alias -Status Completed))
		Start-Sleep -s 300

Open in new window

Any help would be greatly appreciated.
Question by:rye004
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions

Expert Comment

by:David Sankovsky
ID: 41760575
I haven't a ready code, but if you use Get-Mailbox <mailbox> |fl ArchiveDataBase you should get an empty string if it has none.

That should help you filter out which mailboxes do have archives.

Accepted Solution

Ibrahim Benna earned 2000 total points
ID: 41760886
To add on to David's suggestion, you can run the following command to get you a list of mailboxes that only have archives

get-mailbox | where {$_.ArchiveDatabase -ne $null}

To do the opposite and find mailboxes without any archive mailboxes run this

get-mailbox | where {$_.ArchiveDatabase -eq $null}

Author Comment

ID: 41761360
DeBlackman,  Thank you for your input, it was very helpful.  I have written the following below which I think is going to work.
function ExportMailBox ($mailBoxName, $isArchive, $outputPath){

    #Call New-MailboxExportRequest here.


"mailboxes with an archive:"
foreach ($mailBoxName in (Get-Mailbox | where {$_.ArchiveDatabase -ne $null})){

    ExportMailBox -mailBoxName $mailBoxName, -isArchive False, -outputPath "...."
    ExportMailBox -mailBoxName $mailBoxName, -isArchive True, -outputPath "...."


"mailboxes without an archive:"
foreach ($mailBoxName in (Get-Mailbox | where {$_.ArchiveDatabase -eq $null})){

    ExportMailBox -mailBoxName $mailBoxName, -isArchive False, -outputPath "...."


Open in new window


Featured Post

NEW Veeam Agent for Microsoft Windows

Backup and recover physical and cloud-based servers and workstations, as well as endpoint devices that belong to remote users. Avoid downtime and data loss quickly and easily for Windows-based physical or public cloud-based workloads!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Auditing domain password hashes is a commonly overlooked but critical requirement to ensuring secure passwords practices are followed. Methods exist to extract hashes directly for a live domain however this article describes a process to extract u…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
In this video we show how to create an Accepted Domain in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Mail Flow >> Ac…
In this Micro Video tutorial you will learn the basics about Database Availability Groups and How to configure one using a live Exchange Server Environment. The video tutorial explains the basics of the Exchange server Database Availability grou…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question