简体   繁体   English

Exchange命令行管理程序 - Exchange 2010 - 使用DateRange导出到PST,忽略过滤

[英]Exchange Management Shell - Exchange 2010 - Exporting with DateRange to PST ignoring the filtering

I'll elaborate on the title a bit. 我稍微详细说明一下这个标题。

I'm currently creating a script to export a mailbox on Exchange 2010 to a PST, only emails from a specific date range. 我目前正在创建一个脚本,将Exchange 2010上的邮箱导出到PST,只发送来自特定日期范围的电子邮件。

However, it seems to be ignoring the filter and exporting all 37gb to a PST. 但是,似乎忽略了过滤器并将所有37gb导出到PST。

I'm creating the script to prevent having to do it in the future. 我正在创建脚本以防止将来必须这样做。 I will post the script below, as it is all relevant to the issue due to variables etc. 我将发布下面的脚本,因为它与变量等问题都有关。

# / 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

Apologies about the bulk, I can't personally see an error. 对批量道歉,我不能亲自看到错误。

Ended up fixing this myself after A LOT of playing around. 经过大量的游戏后,我自己完成了修复。

Had to throw the filter into it's own parameter, like so 不得不把过滤器扔进它自己的参数,就像这样

$filter = "(Received -ge" + " " + $StartDate + ") -and (Received -le" + " " + $EndDate + ")"

then pipe it into the command 然后将其输入命令

$Request = New-MailboxExportRequest -ContentFilter $filter -Mailbox $User -Name $ReqName -FilePath $PSTPath

This has allowed it to progress 这使它得以进步

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用Exchange命令行管理程序将邮箱属性从Exchange 2010导出到CSV - Exporting Mailbox Attributes from Exchange 2010 to CSV using Exchange Management Shell Exchange命令行管理程序默认Exchange Server - Exchange Management Shell Default Exchange Server 如何获取用户有权访问Exchange2010的所有共享邮箱的列表| 是Exchange命令行管理程序还是PowerShell? - How to get a list of all the Shared Mailboxes that a user have access to Exchange2010 | Exchange Management Shell or PowerShell? 为什么相同的脚本在 Exchange Management Shell 2010 中有效,但不能通过 C# 与 Powershell 和 Exchange Connection - Why does the same script work in Exchange Management Shell 2010 but not through C# with Powershell and Exchange Connection ADInvalidCredentialException 与 Exchange 2010 的 PowerShell 远程管理 - ADInvalidCredentialException with PowerShell remote management for Exchange 2010 Exchange命令行管理程序未连接到最近的Exchange服务器 - Exchange Management Shell doesn't connect to closest Exchange server 从C#调用Exchange命令行管理程序 - Invoking Exchange Management Shell from C# C#以编程方式导出运输规则-Exchange 2010 - c# programatically exporting transport rule - exchange 2010 我可以在Exchange Server 2010 SP3上将邮箱导出到PST排队吗? - Can I queue mailbox export to PST on Exchange Server 2010 SP3? C#已连接到Powershell,但是我需要连接到Exchange命令行管理程序 - C# Connected to Powershell, but I need connect to Exchange Management Shell
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM