Export Mailboxes with Online Archive in Exchange 2010
-
Tuesday, February 26, 2013 5:47 PM
I currently have a script that will export mailboxes of terminated users from Exchange 2010 to PST which includes their Contacts and Calendar. This is the code I am using.
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
However now I need to modify my script to check if the mailbox has Online Archiving enabled. If it does have Online Archiving enabled I need to export that too with the PST name of FirstName.LastName(Archive).pst.
I know I need to use these 2 lines of code however I can't seem to figure out how to determine if the mailbox has online archiving enabled.
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
New-MailboxExportRequest -Mailbox FirstName.LastName -IsArchive -FilePath \\Server\ArchivedMailboxes\FirstName.LastName(Archive).pst -IncludeFolders "#Calendar#", "#Contacts#"
Any help on how I can determine if the mailbox has Online Archiving and if it does to export the Online Archive mailbox as well?
All Replies
-
Wednesday, February 27, 2013 3:17 AM
If you use Get-Mailbox you can get the ArchiveStatus, something like this:
if ((Get-Mailbox FirstName.LastName).ArchiveStatus -ne "None") { New-MailboxExportRequest ..... }Best Regards
Claus Codam
Consultant, Developer
Coretech - Blog- Marked As Answer by IamMredMicrosoft Employee, Owner Tuesday, March 05, 2013 4:25 AM
-
Wednesday, February 27, 2013 3:15 PMWhen I go to test with just (Get-Mailbox FirstName.LastName).ArchiveStatus I keep getting the response of None. Doesn't matter if the account has online archiving enabled or not.
-
Wednesday, February 27, 2013 3:36 PM
It seems that I've misunderstood the purpose of ArchiveStatus, apparently it's not used for whether Archiving is enabled or disabled. Perhaps it's used for Warning/Error status?
However you can use .ArchiveDatabase or .ArchiveName and check if it's -ne ""
Or you can use the .ArchiveGUID and check if its -ne [guid]::empty
Best Regards
Claus Codam
Consultant, Developer
Coretech - Blog- Proposed As Answer by Claus Codam Wednesday, February 27, 2013 4:24 PM
- Marked As Answer by IamMredMicrosoft Employee, Owner Tuesday, March 05, 2013 4:25 AM
-
Wednesday, February 27, 2013 3:46 PM
I figured it out. I am posting my code in case anyone else ever needs it.
if ((Get-Mailbox FirstName.LastName).ArchiveDatabase -ne "ArchiveDatabase") {
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
} elseif ((Get-Mailbox FirstName.LastName).ArchiveDatabase -eq "ArchiveDatabase") {
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
New-MailboxExportRequest -Mailbox FirstName.LastName -IsArchive -FilePath \\Server\ArchivedMailboxes\FirstName.LastName(Archive).pst -IncludeFolders "#Calendar#", "#Contacts#"
}- Edited by NhanDISYS Wednesday, February 27, 2013 8:19 PM
-
Wednesday, February 27, 2013 4:24 PM
Yep, of cause you will need to adjust the Archive Database name accordingly, will it always be "ArchiveDatabase" in your environment? if not, consider using one of the possibilities I listed in the above post. .ArchiveDatabase -eq "" and a simple Else without statement would work just as well.
Best Regards
Claus Codam
Consultant, Developer
Coretech - Blog -
Wednesday, February 27, 2013 5:47 PM
Heh I made some modifications and used your ArchiveGUID idea. The issue is when I export the mailboxes right now it is only exporting contacts and calendars. I thought the -IncludeFolders meant that it would do the mailboxs and those folders not just those 2 items. When I don't use the -IncludeFolders it just exports the emails but not contacts or calendar. Here is my code.
if ((Get-Mailbox FirstName.LastName).ArchiveGUID -eq [guid]::empty) {
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
} elseif ((Get-Mailbox FirstName.LastName).ArchiveGUID -ne "[guid]::empty") {
New-MailboxExportRequest -Mailbox FirstName.LastName -FilePath \\Server\ArchivedMailboxes\FirstName.LastName.pst -IncludeFolders "#Calendar#", "#Contacts#"
New-MailboxExportRequest -Mailbox FirstName.LastName -IsArchive -FilePath \\Server\ArchivedMailboxes\FirstName.LastName-Archive.pst -IncludeFolders "#Calendar#", "#Contacts#"
}- Edited by NhanDISYS Wednesday, February 27, 2013 8:18 PM

