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

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

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

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

Steps to fix “Unable to mount database. (hr=0x80004005, ec=1108)”.
If you have come across a situation where you need to find some EDB mailbox recovery techniques, then here you will find the same. In this article, we will take you through three techniques using which you will be able to perform EDB recovery. You …
This video demonstrates how to sync Microsoft Exchange Public Folders with smartphones using CodeTwo Exchange Sync and Exchange ActiveSync. To learn more about CodeTwo Exchange Sync and download the free trial, go to: http://www.codetwo.com/excha…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Suggested Courses

840 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