我有一个可以运行的脚本,但我不是高级程序员。有人能按照我的要求修改我的脚本吗?
1) 邮箱应从特定服务器“ServerX”导出。目前,此脚本会扫描所有 Exchange 数据库。
2) 只是为了验证每次运行此脚本时,它是否应该准确地将上个月的备份复制到所需的共享位置。假设在 2015 年 12 月 9 日运行此脚本,它应该从 2015 年 11 月 9 日备份到 2015 年 12 月 9 日。
3)脚本的下半部分在检查导出请求时从未起作用。有人能建议需要进行哪种修改吗?
$Export = Get-Mailbox
$endDate = Get-Date "00:00:00"
$startDate = $endDate.AddDays(-30)
$month = "{0:D2}" -f [int]$startDate.Month
$year = "{0:D4}" -f [int]$startDate.Year
Write-Host -NoNewline "Exporting items between $startDate and $endDate..."
$Export|%{$_|New-MailboxExportRequest -ContentFilter {(Received -ge $startDate) -and (Received -lt $endDate)} -FilePath "\\FileServer\EmailBackups\ExportTest\Test\$($_.alias).pst"}
Write-Host "Done."
**After this script gives error. But mailboxes exported successfully.**
Write-Host -NoNewline "Waiting for export to complete..."
While(!(Get-MailboxExportRequest -Mailbox $Exprot -Status Completed))
{
#Sleep for a few minutes
Write-Host -NoNewline "."
Start-Sleep -s 60
}
Write-Host "Done."
Write-Host -NoNewline "Removing Export Request..."
Get-MailboxExportRequest -Mailbox $Export -Status Completed | Remove-MailboxExportRequest
Write-Host "Done."