基本的に、次の結果を保持する新しい変数を作成する必要があります。
Get-Mailbox -database Accounting)
次に、その変数のカウントのパーセンテージまたは特定の数値を使用して、プログラムでバッチ番号を決定できます。
$myEmailBoxes = Get-Mailbox -database Accounting
$myEmailBoxes.count
リストの合計に含まれるメールボックスの数がわかります。ただし、これは exchange powershell の正確な構文ではない場合があります。テスト中にEcho
、期待どおりの結果が得られていることを確認できるように、結果を出力したい場合があります。
トランザクションをバッチ処理するには、for each の代わりに「for」ループを使用し、バッチ処理する数に設定します。
次のようになります。
$allMailboxes = Get-Mailbox -database Adjunct
$batchSize = 2
$currentBatchIndex = 0
$currentBatchMailboxes
# Call the function to start the process
batchMailboxes
function batchMailboxes {
for (i = $currentBatchIndex; i < $currentBatchIndex + $batchSize; i++)
{
$currentBatchMailboxes += $allMailboxes[i]
$currentBatchIndex++
}
exportBatchedMailboxes($currentBatchMailboxes)
$batchStatus = getBatchedMailboxStatus($currentBatchMailboxes)
if ($batchStatus == false) {
#Execute timer to get getBatchedMailboxStatus($currentBatchMailboxes)
}
else {
if ($currentBatchIndex < $allMailboxes.count - 1) {
batchMailboxes
}
}
}
function exportBatchedMailboxes ($exportMailboxes)
{
foreach ($i in $exportMailboxes) {
New-MailboxExportRequest -Mailbox $i -FilePath "backuplocation\Adjunct\$($i.Alias).pst" -baditemlimit 50 -acceptlargedataloss
}
}
function getBatchedMailboxStatus ($batch)
{
# command for checking status needs to go here using a foreach loop
}
これは完全に機能するスクリプトの完全な実装ですhttp://blog.bluepegasusinc.com/index.php/batch-export-exchange-2010-mailbox-to-pst/