Domanda

I have an Exchange 2010 environment with about 1000 users across 6 databases. They all have archives enabled that are stored in separate databases.

I have backup software that gets the database, but I want to supplement this by doing a .pst export of mailboxes directly from Exchange. I want to take all the users in a given database and export to .pst. My command looks like below:

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

The problem with this is it exports them all at once (killing our server resources) and half of them fail because there are too many running at once. I'd like a script to backup about 20 mailboxes at a time. Any help is appreciated.

È stato utile?

Soluzione

Basically you're going to want to create a new variable that holds the results of Get-Mailbox -database Accounting)

Then you can determine batch numbers programmatically using a percentage of the count of that variable or a specific number.

$myEmailBoxes = Get-Mailbox -database Accounting

$myEmailBoxes.count should give you how many mailboxes are in the list total. This may not be the exact syntax for exchange powershell though. While you're testing you may want to Echo the results to the output so you know that you are getting what you expect.

To batch the transactions use a 'for' loop instead of a for each and set it to the number you want to batch.

It would look something like the following:

$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
}

Here's a full implementation of the script that works perfectly http://blog.bluepegasusinc.com/index.php/batch-export-exchange-2010-mailbox-to-pst/

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top