I'm trying to export all my mailboxes to individual pst through powershell.
I have no issue for small mailboxes. For larger ones, the export-cexitem cmdlet seems to be buggy and the bug seems to be related to the write-progress included in the cmdlet and the initial count item to display this progress bar.
At the start of the export, the cmdlet is counting the items. Then it is processing the export and the pst file is growing. At the end of the progress bar, the export continue, powershell is starting to display errors and the pst continue to grow. I let it ran for a couple hours and the pst were still growing.
To compare, I ran this export for this particular mailbox through the GUI, and the pst is around 15GB. However, it reproduce the "counting" error since the export really finished a couple minutes after the "100%" is displayed.
Here you can see the exporting is getting more items than expected:
Anyone have this issue and know a workaround ? I am also suspecting the particular language of the server.
I tried to disabled the write-progress with: $ProgressPreference = "SilentlyContinue"
but the issue persists.
I also tried with a limit of 10GB without luck.
Some parts of the script:
Code: Select all
import-module Veeam.Archiver.PowerShell
Import-Module -Name AWSPowerShell
Start-Transcript -Path "G:\Export-To-Cloudian\$(get-date -f yy-M-d)-1.log"
$exportDate = "01/01/2020"
$folderExport = $exportDate -replace "/","-"
$restorepoint = Get-VBORestorePoint
$choices = $restorepoint | Where-Object {$_.BackupTime -like "$exportDate*"}
$organization = Get-VBOOrganization -Name "xxxxxxxx"
Start-VBOExchangeItemRestoreSession -RestorePoint $choices[0] -Organization $organization
$session = Get-VBOExchangeItemRestoreSession
$database = Get-VEXDatabase -Session $session
$mailboxes = Get-VEXMailbox -Database $database
$mailboxes | Export-CSV -LiteralPath "G:\Export-To-Cloudian\csv-$($folderExport).csv" -NoTypeInformation -Encoding UTF8
$cpt = -1
#disable bugged progress bar
$OriginalPref = $ProgressPreference # Default is 'Continue'
$ProgressPreference = "SilentlyContinue"
foreach ($user in $mailboxes) {
$cpt++
if ($cpt -lt 2) {
#skip the n first mailboxes (already backuped)
continue
}
# Create folder
md -Force "G:\Export-To-Cloudian\$folderExport\" | out-null
# Export PST
$mailbox = Get-VEXMailbox -Database $database -name $user
Write-Host "$cpt - Exporting $($mailbox.name) to G:\Export-To-Cloudian\$folderExport\$($mailbox.name).pst"
Export-VEXItem -Mailbox $mailbox -To "G:\Export-To-Cloudian\$folderExport\$($mailbox.name).pst" -PstSizeLimit 10
}
$ProgressPreference = $OriginalPref
Stop-Transcript