0
我正在嘗試創建一個腳本,可以將用戶的郵箱遠程導出到PST(Exchange Server 2010控制檯安裝在我們運行此服務器的服務器上,而模塊正確加載)。這是使用腳本完成的,因此我們的L2管理員不必手動執行任務。這是MWE。`New-MailboxExportRequest`的早餐欄
$UserID = Read-Host "Enter username"
$PstDestination = "\\ExServer\Share\$UserID.pst"
$Date = Get-Date -Format "yyyyMMddhhmmss"
$ExportName = "$UserID" + "$Date"
try {
New-MailboxExportRequest -Mailbox $UserID -FilePath $PstDestination -Name $ExportName -ErrorAction Stop -WarningAction SilentlyContinue | Out-Null
# Loop through the process to track its status and write progress
do {
$Percentage = (Get-MailboxExportRequest -Name $ExportName | Get-MailboxExportRequestStatistics).PercentComplete
Write-Progress "Mailbox export is in progress." -Status "Export $Percentage% complete" -PercentComplete "$Percentage"
}
while ($Percentage -ne 100)
Write-Output "$UserID`'s mailbox has been successfully exported. The archive can be found at $PstDestination."
}
catch {
Write-Output "There was an error exporting the mailbox. The process was aborted."
}
的問題是,當我們開始出口,這項工作變得Queued
。有時候,導出仍會排隊很長時間,腳本目前無法確定任務何時開始,何時開始,無法正確顯示進度。導出發生在後臺,但腳本仍然停留在那裏。所以出口後的任何事情都不會被執行,整個事情都必須手動完成。
請提出處理方法?
我試着添加一個等待計時器,然後檢查導出是否已經開始。它沒有像預期的那樣工作。