0
votes

I am in a situation, when I would like to queue a few mailboxes to export (I don't want them to be processed at the same time) to PST files. I know, how to export them it with a command get-mailboxexportrequest, but when I do it, they almost instantly begin. Can I somehow queue another mailbox, so it would automatically start, when the previous one is completed?

1
If you have a list of mailboxes or mailbox IDs in an array, you should be able to pipe that to a ForEach-Object which runs New-MailboxExportRequest for each mailbox, assuming that command runs synchronously. You'd have to write it to be able to determine a unique filename for each mailbox, but that shouldn't be difficult.Bacon Bits
are you sure about this? the command to request migration ends quite quickly - you don't have to wait until the process is complete, i think in that case "for each" would just begin all the other requests, or am I wrong in here?kjubus
No, I'm not sure at all, that's why I said, "assuming [New-MailboxExportRequest] runs synchronously." Browsing the doc for that cmdlet, it seems to imply the system uses a request queue, however. Alternately, you could specify the -Suspend parameter to start all requests suspended. You could then basically manage the queue yourself.Bacon Bits

1 Answers

0
votes

I would do the following:

  • Build a powershell script which is checking if there is a running export happening (via Get-MailboxExportRequest) if that isn´t the case start to export x mailfiles you specify inside a CSV file
  • Use the Windows taskmanager on your Exchange Server to trigger that script and define a timeframe here how often and when your script should run
  • Once the powershell script runs, it should remove the exported mailfile from the CSV file and then quit
  • The next run from the powershell script via the taskmanager will then check if the current job is still ongoing, if it is, it should quit until its time to pick up the next entry from your list

Update:

As a starting point something like the following should be fine (untested but should give you a starting point):

# Get current Export Requests
$ExportStats = Get-MailboxExportRequest

#Check if there are completed questes
If ($ExportStats.Status -eq "Completed")
{
  Write-Host "Export done"
  Get-MailboxExportRequest -Status Completed -Name "$ObjectName-Export" | Remove-MailboxExportRequest -Confirm:$false
  #Disable-Mailbox -identity "AD\$ObjectName"

  # Create a new CSV file, which isn´t including the current export name we just marked as finish via above's section.      
  # CODE MISSING HERE!      

  # Now import our CSV list and proceed it
  Import-CSV <Filepath of CSV file(\\server\folder\file.csv)> | ForEach-Object {
  # Perform the export
  New-MailboxExportRequest -Mailbox $_.MailboxAlias -FilePath $_.PSTpath
  New-MailboxExportRequest -Mailbox $_.MailboxAlias -FilePath $_.ArchivePath
  # Once done exit here, this will ensure we proceed only the first entry
  Exit
  } 

}
elseif ($ExportStats.Status -eq "InProgress")
{
    Write-Host "Export still ongoing"    
}