From 3a08ff76a7820fda8511d95fea7eed802bbb0fa3 Mon Sep 17 00:00:00 2001 From: Danny de Kooker Date: Wed, 5 Mar 2025 22:17:50 +0100 Subject: [PATCH] Changed the reporting of the export stats --- Exchange/Export-all-mailboxes.ps1 | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/Exchange/Export-all-mailboxes.ps1 b/Exchange/Export-all-mailboxes.ps1 index cec9a2a..66c25d3 100644 --- a/Exchange/Export-all-mailboxes.ps1 +++ b/Exchange/Export-all-mailboxes.ps1 @@ -9,7 +9,8 @@ foreach ($Mailbox in $Mailboxes) { $CurrentMailbox++ # 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..." @@ -17,8 +18,8 @@ foreach ($Mailbox in $Mailboxes) { Start-Sleep -Seconds 5 # Wait before checking again # Check if the mailbox export is still in progress - $ExportRequest = Get-MailboxExportRequest -Mailbox $Mailbox.Identity | Where-Object { $_.Status -ne "Completed" } - $ExportStats = Get-MailboxExportRequestStatistics -Mailbox $Mailbox.Identity -ErrorAction SilentlyContinue + $ExportRequest = Get-MailboxExportRequest -Name $ExportName | Where-Object { $_.Status -ne "Completed" } + $ExportStats = Get-MailboxExportRequest -Name $ExportName | Get-MailboxExportRequestStatistics -ErrorAction SilentlyContinue # Get completion percentage of the current mailbox export $MailboxPercentComplete = if ($ExportStats) { $ExportStats.PercentComplete } else { 0 }