Exchange 2010批量导出邮箱到.pst

时间:2013-02-06 17:07:36

标签: loops export exchange-server-2010 pst

我有一个Exchange 2010环境,在6个数据库中有大约1000个用户。它们都启用了存档,存储在不同的数据库中。

我有备份软件来获取数据库,但我想通过直接从Exchange进行邮箱的.pst导出来补充这一点。我想获取给定数据库中的所有用户并导出到.pst。我的命令如下所示:

foreach ($i in (Get-Mailbox -database Accounting)) { 
    New-MailboxExportRequest -Mailbox $i -FilePath "\\server\D$\PSTBackup\test\Accounting\$($i.Alias).pst" -baditemlimit 50 -acceptlargedataloss 
}

这个问题是它一次性导出它们(杀死我们的服务器资源),其中一半失败,因为一次运行太多。我想要一个脚本一次备份大约20个邮箱。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:0)

基本上你会想要创建一个保存结果的新变量 Get-Mailbox -database Accounting)

然后,您可以使用该变量的计数百分比或特定数字以编程方式确定批号。

$myEmailBoxes = Get-Mailbox -database Accounting

$myEmailBoxes.count应该会显示列表总数中有多少个邮箱。这可能不是交换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/

的完整脚本实现