Exchange 管理 Shell - Exchange 2010 - 使用 DateRange 导出到 PST 忽略过滤
Exchange Management Shell - Exchange 2010 - Exporting with DateRange to PST ignoring the filtering
我会详细说明标题。
我目前正在创建一个脚本来将 Exchange 2010 上的邮箱导出到 PST,仅导出特定日期范围内的电子邮件。
但是,它似乎忽略了过滤器并将所有 37gb 导出到 PST。
我正在创建脚本以防止将来不得不这样做。我将post下面的脚本,因为它与变量等问题有关
# / Sets to US Date Values \ #
[System.Reflection.Assembly]::LoadWithPartialName("System.Threading")
[System.Reflection.Assembly]::LoadWithPartialName("System.Globalization")
[System.Threading.Thread]::CurrentThread.CurrentCulture = [System.Globalization.CultureInfo]::CreateSpecificCulture("en-us")
# / This Loads The Assemblies Required for Data Input for the future Parameters \ #
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
[System.Windows.Forms.Application]::EnableVisualStyles() | Out-Null
# / This Loads The Pop-up Data Input Windows For Creating the Parameters \ #
Add-Type -AssemblyName Microsoft.VisualBasic
# / Parameter Creation Using Nice GUI Pop-Up Windows \ #
$User = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The Email Account?', 'Email Address', "Email@Email.com")
$StartDateData = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The Start Date (US Date Format)', 'Start Date', "12/25/1900")
$EndDateData = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The End Date (US Date Format)', 'End Date', "12/25/1900")
$Path = [Microsoft.VisualBasic.Interaction]::InputBox('Specify Where You Want The PST to Be Saved (Full UNC Path WITH Trailing Slash)', 'Path', "C:\Users\%USERPROFILE%\Desktop\")
# / Export Mailbox \ #
cls
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host 'Is this Data Correct?'
Write-Host ''
Write-Host ''
Write-Host $User
Write-host $StartDateData
Write-host $EndDateData
write-host $Path
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host "Do You Want To Continue? (Y/N)"
$response = Read-Host
if ( $response -ne "Y" ) {
exit
}
cls
# / Sets The Path Parameter \ #
$PSTPath = $Path + $User + ".pst"
# / Sets The Date Parameter \ #
$StartDate = "'" + $StartDateData + "'"
$EndDate = "'" + $EndDateData + "'"
# Use This if the Below Doesn't Work - Export-Mailbox -Identity $User -StartDate $StartDate -EndDate $EndDate -PstFolderPath $PSTPath
# gt = Greater-Than
# ge = Greater-Than-Or-Equal-To
# lt = Less-Than
# le = Less-Than-Or-Equal-To
$Request = New-MailboxExportRequest -Mailbox $User -ContentFilter {(Received -ge $StartDate) -and (Received -le $EndDate)} -FilePath $PSTPath
$Status = ( Get-MailboxExportRequestStatistics -Identity $Request ).Status.ToString().Trim()
while( $Status -ne 'Completed' ){
Start-Sleep 10
$Status = ( Get-MailboxExportRequestStatistics -Identity $Request ).Status.ToString().Trim()
Write-Verbose "Current Export Status: $Status" -Verbose
}a
Write-Verbose "$Mailbox exported" -Verbose
请见谅,我个人看不出错误。
经过大量尝试后最终自己解决了这个问题。
不得不将过滤器放入它自己的参数中,就像这样
$filter = "(Received -ge" + " " + $StartDate + ") -and (Received -le" + " " + $EndDate + ")"
然后通过管道将其输入命令
$Request = New-MailboxExportRequest -ContentFilter $filter -Mailbox $User -Name $ReqName -FilePath $PSTPath
这让它得以进步
我会详细说明标题。
我目前正在创建一个脚本来将 Exchange 2010 上的邮箱导出到 PST,仅导出特定日期范围内的电子邮件。
但是,它似乎忽略了过滤器并将所有 37gb 导出到 PST。
我正在创建脚本以防止将来不得不这样做。我将post下面的脚本,因为它与变量等问题有关
# / Sets to US Date Values \ #
[System.Reflection.Assembly]::LoadWithPartialName("System.Threading")
[System.Reflection.Assembly]::LoadWithPartialName("System.Globalization")
[System.Threading.Thread]::CurrentThread.CurrentCulture = [System.Globalization.CultureInfo]::CreateSpecificCulture("en-us")
# / This Loads The Assemblies Required for Data Input for the future Parameters \ #
[System.Reflection.Assembly]::LoadWithPartialName("System.Windows.Forms") | Out-Null
[System.Reflection.Assembly]::LoadWithPartialName("System.Drawing") | Out-Null
[System.Windows.Forms.Application]::EnableVisualStyles() | Out-Null
# / This Loads The Pop-up Data Input Windows For Creating the Parameters \ #
Add-Type -AssemblyName Microsoft.VisualBasic
# / Parameter Creation Using Nice GUI Pop-Up Windows \ #
$User = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The Email Account?', 'Email Address', "Email@Email.com")
$StartDateData = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The Start Date (US Date Format)', 'Start Date', "12/25/1900")
$EndDateData = [Microsoft.VisualBasic.Interaction]::InputBox('What Is The End Date (US Date Format)', 'End Date', "12/25/1900")
$Path = [Microsoft.VisualBasic.Interaction]::InputBox('Specify Where You Want The PST to Be Saved (Full UNC Path WITH Trailing Slash)', 'Path', "C:\Users\%USERPROFILE%\Desktop\")
# / Export Mailbox \ #
cls
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host 'Is this Data Correct?'
Write-Host ''
Write-Host ''
Write-Host $User
Write-host $StartDateData
Write-host $EndDateData
write-host $Path
Write-Host ''
Write-Host ''
Write-Host ''
Write-Host "Do You Want To Continue? (Y/N)"
$response = Read-Host
if ( $response -ne "Y" ) {
exit
}
cls
# / Sets The Path Parameter \ #
$PSTPath = $Path + $User + ".pst"
# / Sets The Date Parameter \ #
$StartDate = "'" + $StartDateData + "'"
$EndDate = "'" + $EndDateData + "'"
# Use This if the Below Doesn't Work - Export-Mailbox -Identity $User -StartDate $StartDate -EndDate $EndDate -PstFolderPath $PSTPath
# gt = Greater-Than
# ge = Greater-Than-Or-Equal-To
# lt = Less-Than
# le = Less-Than-Or-Equal-To
$Request = New-MailboxExportRequest -Mailbox $User -ContentFilter {(Received -ge $StartDate) -and (Received -le $EndDate)} -FilePath $PSTPath
$Status = ( Get-MailboxExportRequestStatistics -Identity $Request ).Status.ToString().Trim()
while( $Status -ne 'Completed' ){
Start-Sleep 10
$Status = ( Get-MailboxExportRequestStatistics -Identity $Request ).Status.ToString().Trim()
Write-Verbose "Current Export Status: $Status" -Verbose
}a
Write-Verbose "$Mailbox exported" -Verbose
请见谅,我个人看不出错误。
经过大量尝试后最终自己解决了这个问题。
不得不将过滤器放入它自己的参数中,就像这样
$filter = "(Received -ge" + " " + $StartDate + ") -and (Received -le" + " " + $EndDate + ")"
然后通过管道将其输入命令
$Request = New-MailboxExportRequest -ContentFilter $filter -Mailbox $User -Name $ReqName -FilePath $PSTPath
这让它得以进步