Bulk Export of Exchange Mailboxes from a Collection

I am currently looking at performing a bulk export of mailboxes from Exchange 2010 using the New-MailboxExportRequest cmdlet from a collection within a CSV file.

Firstly, I will want to remove any existing Mailbox Export Requests as I want to provide the status of the bulk export as the final step of the process with no previous history.

Get-MailboxExportRequest | Remove-MailboxExportRequest

Now, I want to generate the collection of mailboxes from reading the content of a file, which contains only the alias of each mailbox. In the below example, I am using the filename \\Server\Share\MailboxAlias.csv.

$Aliases = Get-Content "\\Server\Share\MailboxAlias.csv"

Now I want to request a mailbox export for each mailbox in the collection and export the PST with the Mailbox Name as the filename.  Therefore, the script block will firstly return all the mailbox attributes based on the mailbox alias name in the collection.

Also, by default Microsoft Exchange will auto generate 10 unique names for each mailbox export request. In this instance this is an insufficient amount to complete the bulk export. Therefore, we will specify the mailbox alias as the mailbox export request name.

ForEach ($Alias in $Aliases) 
{ 
$Mailbox = Get-Mailbox -Identity $Alias
New-MailboxExportRequest -Name $Mailbox.Alias -Mailbox $Mailbox.Alias -FilePath "\\Server\Share\" + $Mailbox.Name + ".pst"
}

At the final stage of the process I want to export the mailbox request status, therefore I will need to suspend the collection of this until all the export requests are reported as Completed.

I will perform this step by returning the mailbox export requests until all items are Completed and then export the mailbox request status to a CSV.

Do { 
$Queue = Get-MailboxExportRequest | Where-Object {$_.Status -ne "Completed"} 
} 
Until ($Queue -eq $null)

Get-MailboxExportRequest | Export-Csv "\\Server\Share\GetMailboxExportRequest.csv" -NoTypeInformation