如何使用PowerShell检查Exchange 2010中是否已读取电子邮件?

时间:2015-12-15 17:06:36

标签: powershell exchange-server-2010

我们正在搜索Exchange 2010的收件箱,并尝试找出指定用户/邮箱读取的特定电子邮件。

我们可以利用powershell进行搜索,不确定如何执行此操作

1 个答案:

答案 0 :(得分:0)

您可以使用Exchange Web服务。 You will need to download the API.这将要求运行脚本的用户有权访问相关邮箱,并且您知道要查找的电子邮件的主题。

Import-Module -Name "C:\Program Files\Microsoft\Exchange\Web Services\Microsoft.Exchange.WebServices.dll"

$exchService = New-Object Microsoft.Exchange.WebServices.Data.ExchangeService([Microsoft.Exchange.WebServices.Data.ExchangeVersion]::Exchange2010)
$exchService.AutodiscoverUrl("email@yourdomain.com",{$true})

$Mailbox = New-Object Microsoft.Exchange.WebServices.Data.Mailbox("email@yourdomain.com")
$Inbox = [Microsoft.Exchange.WebServices.Data.Folder]::Bind($exchservice,[Microsoft.Exchange.WebServices.Data.WellKnownFolderName]::Inbox)

$MessageView = New-Object Microsoft.Exchange.WebServices.Data.ItemView(100) #Find Max 100 Items

$SerachFilter1 = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::Subject,"Test Subject")
$SerachFilter2 = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+IsEqualTo([Microsoft.Exchange.WebServices.Data.EmailMessageSchema]::IsRead, $false)
$SearchFilterCollection = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+SearchFilterCollection([Microsoft.Exchange.WebServices.Data.LogicalOperator]::And)
$SearchFilterCollection.Add($SerachFilter1)
$SearchFilterCollection.Add($SerachFilter2)

If($Messages.TotalCount > 0){

    #Do something....
}