Exchange Powershell 错误发生在几个月前完全正常的事情上?
Exchange Powershell Error on Something that totally functioned a few months ago?
我几个月前写这篇文章是为了遍历几个域和一个用户列表,并让我读出每个用户收到的来自所列域的电子邮件数量。现在我遇到了一些非常奇怪的错误,我只是不知道它在说什么。
这是代码和错误
[long]$IntSent=0
[long]$IntRec=0
[long]$IntTotal=0
$startdate="06/09/2018 00:00:01"
$enddate="06/12/2018 23:59:59"
$domains=@(REDACTED) #etc
$users=@(REDACTED)
ForEach ($user in $users) {
foreach ($domain in $domains) {
get-messagetrackinglog -start $startdate -End $enddate -Recipients $users -resultsize unlimited -EventID Receive | where {[string]$_.sender -like "*@$domain"} |ForEach{$IntRec++}
#|Where {[String]$_.recipients -notlike "*@contoso4.com*"}
}
}
错误:
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
想法?我不知道在哪里看这里。
这个问题很可能与代理地址过多有关。如您所见here(不在答案中,而是在下方):
if the mailbox has more than 49 proxy addresses entered within the Email addresses tab the search command will fail
这可以解释为什么它以前可以工作而现在不工作。虽然通常解决方案是检查是否有任何用户拥有超过 49 个代理地址,但这里可能不是这种情况。
在你的 ForEach
你使用
-Recipients $users
所以基本上,对于每个用户,您都会从列表中搜索发送给 所有 用户的消息。您可能想要使用的是(注意缺少 s
)
-Recipients $user
此外,如果我可以提出一些建议(作为一个好习惯)——我通常在使用 ForEach
迭代时使用一个字符变量,如下所示:
ForEach ($u in $users)
ForEach ($d in $domains)
有了这个习惯,您就可以最大限度地减少在 ForEach
中使用不正确变量的可能性,就像在该脚本中一样。
我几个月前写这篇文章是为了遍历几个域和一个用户列表,并让我读出每个用户收到的来自所列域的电子邮件数量。现在我遇到了一些非常奇怪的错误,我只是不知道它在说什么。
这是代码和错误
[long]$IntSent=0
[long]$IntRec=0
[long]$IntTotal=0
$startdate="06/09/2018 00:00:01"
$enddate="06/12/2018 23:59:59"
$domains=@(REDACTED) #etc
$users=@(REDACTED)
ForEach ($user in $users) {
foreach ($domain in $domains) {
get-messagetrackinglog -start $startdate -End $enddate -Recipients $users -resultsize unlimited -EventID Receive | where {[string]$_.sender -like "*@$domain"} |ForEach{$IntRec++}
#|Where {[String]$_.recipients -notlike "*@contoso4.com*"}
}
}
错误:
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
The server software doesn't support the type of search requested.
+ CategoryInfo : InvalidOperation: (:) [Get-MessageTrackingLog], LocalizedException
+ FullyQualifiedErrorId : 6220E2A4,Microsoft.Exchange.Management.TransportLogSearchTasks.GetMessageTrackingLog
+ PSComputerName : MUHSERVER
想法?我不知道在哪里看这里。
这个问题很可能与代理地址过多有关。如您所见here(不在答案中,而是在下方):
if the mailbox has more than 49 proxy addresses entered within the Email addresses tab the search command will fail
这可以解释为什么它以前可以工作而现在不工作。虽然通常解决方案是检查是否有任何用户拥有超过 49 个代理地址,但这里可能不是这种情况。
在你的 ForEach
你使用
-Recipients $users
所以基本上,对于每个用户,您都会从列表中搜索发送给 所有 用户的消息。您可能想要使用的是(注意缺少 s
)
-Recipients $user
此外,如果我可以提出一些建议(作为一个好习惯)——我通常在使用 ForEach
迭代时使用一个字符变量,如下所示:
ForEach ($u in $users)
ForEach ($d in $domains)
有了这个习惯,您就可以最大限度地减少在 ForEach
中使用不正确变量的可能性,就像在该脚本中一样。