Changed the reporting of the export stats
This commit is contained in:
@@ -9,7 +9,8 @@ foreach ($Mailbox in $Mailboxes) {
|
|||||||
$CurrentMailbox++
|
$CurrentMailbox++
|
||||||
|
|
||||||
# Start Export Request
|
# Start Export Request
|
||||||
New-MailboxExportRequest -Mailbox $Mailbox.Identity -FilePath "$ExportPath\$($Mailbox.Alias).pst"
|
$ExportName = "$($Mailbox.Alias)-$(Get-Date -Format "yyyyMMdd-HHmm")"
|
||||||
|
New-MailboxExportRequest -Name $ExportName -Mailbox $Mailbox.Identity -FilePath "$ExportPath\$($Mailbox.Alias).pst"
|
||||||
|
|
||||||
Write-Host "Export started for: $($Mailbox.Alias). Waiting for completion..."
|
Write-Host "Export started for: $($Mailbox.Alias). Waiting for completion..."
|
||||||
|
|
||||||
@@ -17,8 +18,8 @@ foreach ($Mailbox in $Mailboxes) {
|
|||||||
Start-Sleep -Seconds 5 # Wait before checking again
|
Start-Sleep -Seconds 5 # Wait before checking again
|
||||||
|
|
||||||
# Check if the mailbox export is still in progress
|
# Check if the mailbox export is still in progress
|
||||||
$ExportRequest = Get-MailboxExportRequest -Mailbox $Mailbox.Identity | Where-Object { $_.Status -ne "Completed" }
|
$ExportRequest = Get-MailboxExportRequest -Name $ExportName | Where-Object { $_.Status -ne "Completed" }
|
||||||
$ExportStats = Get-MailboxExportRequestStatistics -Mailbox $Mailbox.Identity -ErrorAction SilentlyContinue
|
$ExportStats = Get-MailboxExportRequest -Name $ExportName | Get-MailboxExportRequestStatistics -ErrorAction SilentlyContinue
|
||||||
|
|
||||||
# Get completion percentage of the current mailbox export
|
# Get completion percentage of the current mailbox export
|
||||||
$MailboxPercentComplete = if ($ExportStats) { $ExportStats.PercentComplete } else { 0 }
|
$MailboxPercentComplete = if ($ExportStats) { $ExportStats.PercentComplete } else { 0 }
|
||||||
|
|||||||
Reference in New Issue
Block a user