Reputation: 155
I need to export some PST. Problem is, when I use my foreach-object to export every PST one by one, they are all put in queue. But an other program is supposed to work using the PST at the same time.
dir | foreach-object {
$var = $_
New-MailboxExportRequest -Mailbox $var -Filepath "\\******\******tmp\pst\$var.pst"
}
I dont want my requests to be queued, I want them to be completed before starting an other one. For example, if the first request extracts pst1
, i want it to be fully extracted before putting pst2
in queue. Is there a way to do this ?
Upvotes: 0
Views: 366
Reputation: 8889
You can't change the Queue Behavior but you can force the exchage server to process only 1 pst each time
to achieve this, you need to edit the MSExchangeMailboxReplication.exe.config
file located at:
<Exchange Installation Path>\Program Files\Microsoft\Exchange Server\V14\Bin
MaxActiveMovesPerSourceMDB - Default is 5 - Change it to 1
MaxActiveMovesPerTargetMDB - Default is 2 - Change it to 1
You might also need to change those setting as well:
MaxActiveMovesPerTargetServer
MaxActiveMovesPerSourceServer
of course if you want just to pause the foreach loop you can use the while statement (like Oggew suggested) to make sure the previous job completed before processing the next export
Upvotes: 1
Reputation: 366
You could add something like this after you pass the New-MailboxExportRequest (inside the foreach-loop). If the export status equals "Queued" or "inprogress" the script will sleep for 15s and then check again. If the value changes status to completed it will pass in the next New-MailboxExportRequest.
while ((Get-MailboxExportRequest -Mailbox $var | Where {$_.Status -eq "Queued" -or $_.Status -eq "InProgress"}))
{
sleep 15
}
Upvotes: 0