[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

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

Posted on 2016-08-17
3
Medium Priority
?
271 Views
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.
0
Comment
Question by:rye004
[X]
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
3 Comments
 
LVL 7

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.
0
 
LVL 9

Accepted Solution

by:
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}
0
 

Author Comment

by:rye004
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

0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

Are you an Exchange administrator employed with an organization? And, have you encountered a corrupt Exchange database due to which you are not able to open its EDB file. This article will explain all the steps to repair corrupt Exchange database.
This month, Experts Exchange sat down with resident SQL expert, Jim Horn, for an in-depth look into the makings of a successful career in SQL.
To show how to create a transport rule 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 >> Rules tab.:  To cr…
To show how to generate a certificate request 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 Servers >> Certificates…
Suggested Courses

656 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