ews .finditems()方法正在返回内部服务器
在PowerShell中,我正在尝试绑定到存档邮箱中的文件夹,并运行.finditems()
方法。相关代码示例以下
$ItemView = [Microsoft.Exchange.WebServices.Data.ItemView]::new(500)
$SearchQuery = 'From:"[email protected]" AND HasAttachment:true AND Subject:"New vmail from"'
Do {
# Get a page:
Try {
$ItemCol = $Service.FindItems( $Inbox.Id, $SearchQuery, $ItemView )
# $ItemCol = $Service.FindItems( $Inbox.Id, $ItemView )
}
Catch {
Write-Host -ForegroundColor Red "Error occured running .FindItems()"
Write-Host -ForegroundColor Red $Error[0].Message
Throw
}
$Items += $ItemCol
# ^ Avoid +=, change to simply collect output...
$ItemView.Offset += $ItemCol.Items.Count
$Page++
}While( $ItemCol.MoreAvailable -eq $true )
返回错误:
Exception calling "FindItems" with "3" argument(s): "Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request."
我设法隔离了其中一个交换服务器上的EWS日志条目,其中一部分在下面:
...ErrorTimeoutExpiredException: The search operation could not be completed within the allotted time limit. Please try to narrow down your scope to reduce the result set.
其他提及internalServererror,而HTTP返回代码为500。但是,I不要认为这是一个节流问题,节流策略的EWS部分如下:
EwsCostThreshold : 50
EwsMaxConcurrency : Unlimited
EwsMaxBurst : 300000
EwsRechargeRate : Unlimited
EwsCutoffBalance : Unlimited
EwsMaxSubscriptions : 5000
DiscoveryMaxPreviewSearchMailboxes : 5000
DiscoveryPreviewSearchResultsPageSize : 200
确实,如果我遗漏了搜索查询,尽管搜索所有项目,但虽然会慢得多。我知道的唯一更改是我们升级到Exchange 2019 Cu 12。
我不确定它是否相关,但是在“似乎”的文件夹中,“似乎”的文件夹有超过100,000个项目。也就是说,这种确切的技术是在以前的程序中没有问题的。而且,我能够确认当时存在过多的物品计数。
当该文件夹的项目少于100k的项目时,该代码在主邮箱中的文件夹上运行时工作正常。
在Outlook中,相同的查询在主邮箱和存档邮箱中都可以正常工作。
所以,我很难过。我该如何进一步解决问题?
In PowerShell, I'm attempting to bind to a folder in the archive mailbox and run the .FindItems()
method. Relevant code samples are below
$ItemView = [Microsoft.Exchange.WebServices.Data.ItemView]::new(500)
$SearchQuery = 'From:"[email protected]" AND HasAttachment:true AND Subject:"New vmail from"'
Do {
# Get a page:
Try {
$ItemCol = $Service.FindItems( $Inbox.Id, $SearchQuery, $ItemView )
# $ItemCol = $Service.FindItems( $Inbox.Id, $ItemView )
}
Catch {
Write-Host -ForegroundColor Red "Error occured running .FindItems()"
Write-Host -ForegroundColor Red $Error[0].Message
Throw
}
$Items += $ItemCol
# ^ Avoid +=, change to simply collect output...
$ItemView.Offset += $ItemCol.Items.Count
$Page++
}While( $ItemCol.MoreAvailable -eq $true )
This returns an error:
Exception calling "FindItems" with "3" argument(s): "Exchange Web Services are not currently available for this request because none of the Client Access Servers in the destination site could process the request."
I've managed to isolate EWS log entries on one of the Exchange servers, a segment of which is below:
...ErrorTimeoutExpiredException: The search operation could not be completed within the allotted time limit. Please try to narrow down your scope to reduce the result set.
There are other mentions of InternalServerError and the HTTP return code is 500. However, I don't think this is a throttling issue, EWS portions of the throttling policy are below:
EwsCostThreshold : 50
EwsMaxConcurrency : Unlimited
EwsMaxBurst : 300000
EwsRechargeRate : Unlimited
EwsCutoffBalance : Unlimited
EwsMaxSubscriptions : 5000
DiscoveryMaxPreviewSearchMailboxes : 5000
DiscoveryPreviewSearchResultsPageSize : 200
It is true that if I leave out the search query, getting all items it works, albeit much slower. The only change I'm aware of is that we upgraded to Exchange 2019 CU 12.
I'm not sure if it's related, but the folders generating the error "seem" to have over 100,000 items. That said, this exact technique was used without issue in a previous program. And, I'm able to confirm the excessive item counts were present at the time.
The code works fine when run against a folder in the primary mailbox, although that folder had significantly less than 100K items.
In Outlook, the same query works fine in both the primary and archive mailboxes.
So, I'm stumped. How can I troubleshoot this further?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
确保您使用的是X-anchormailbox标头,因为这将有助于将您的请求路由到正确的服务器/站点。如果您不使用它,请求将得到代理,并且这些类型的超时问题是常见的
Make sure you are using the X-AnchorMailbox header as this will help route your request to the correct server/site. If you don't use it the requests get proxied and these type of timeout issue are common eg