基本上你会想要创建一个新变量来保存结果
Get-Mailbox -database Accounting)
然后,您可以使用该变量的计数百分比或特定数字以编程方式确定批号。
$myEmailBoxes = Get-Mailbox -database Accounting
$myEmailBoxes.count
应该给你列表中总共有多少个邮箱。不过,这可能不是 exchange powershell 的确切语法。在您进行测试时,您可能希望Echo
将结果输出到输出中,以便您知道自己得到了预期的结果。
要批量处理事务,请使用“for”循环而不是 for each,并将其设置为您要批量处理的数量。
它看起来像下面这样:
$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/