无法运行查询以根据Exchange shell上的3个不同条件返回信息

问题描述 投票:0回答:1

交换shell有点新鲜。我想运行查询以返回符合特定条件的交换资源/设备邮箱

Get-mailbox -RecipientTypeDetails RoomMailbox, EquipmentMailbox | foreach-object {Get-CalendarProcessing $_.alias | select identity, AllowConflicts, ConflictPercentageAllowed, MaximumConflictInstances | where {($_.MaximumConflictInstances >=1) -and ($_.AllowConflicts -eq $true) -and ($_.ConflictPercentageAllowed >=1)}}  | export-csv h:\test12346.csv 

但我得到这个错误

out-file : Access to the path 'C:\Windows\System32\=1' is denied.
At line:1 char:212
+ ... nces | where {($_.MaximumConflictInstances >=1) -and ($_.AllowConflicts -eq $tru ...
+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : OpenError: (:) [Out-File], UnauthorizedAccessException
    + FullyQualifiedErrorId : FileOpenFailure,Microsoft.PowerShell.Commands.OutFileCommand

我知道MaximumConflictInstances和/或AllowConflicts参数可能或我的条件语法不正确,因为当我运行下面的命令(部分是初始命令)时,它正常工作正常

Get-mailbox -RecipientTypeDetails RoomMailbox, EquipmentMailbox | foreach-object {Get-CalendarProcessing $_.alias | select ide
ntity, AllowConflicts, ConflictPercentageAllowed, MaximumConflictInstances | where {($_.AllowConflicts -eq $true)}}  | export-csv h:\allowC.csv

我已经尝试了以下,现在看来我错过了一些东西。是否有人能够帮助我查看我的代码并告知我缺少的内容?

Get-mailbox -RecipientTypeDetails RoomMailbox, EquipmentMailbox | foreach-object {Get-CalendarProcessing $_.alias | select identity, AllowConflicts, ConflictPercentageAllowed, MaximumConflictInstances | where {($_.AllowConflicts -eq $true)  -and  {($_.MaximumConflictInstances -gt 1) -OR ($_.ConflictPercentageAllowed -gt 1)}}  | export-csv h:\test12346.csv 

简而言之,我只是尝试导出所有交换室对象和设备对象,如果它们的参数 - allowconflicts设置为TRUE,并且MaximumConflictInstances和ConflictPercentageAllowed等于OR大于1

谢谢Rob

powershell exchange-server exchange-server-2010 selectedindexchanged exchange-server-2007
1个回答
0
投票

进行比较时,PowerShell不使用“> =”比较运算符。它应该如下所示:

where-object { ($_.MaximumConflictInstances -ge 1) -and ($_.AllowConflicts -eq $true) -and ($_.ConflictPercentageAllowed -ge 1)}

您可以在此处查看PowerShell比较运算符:https://docs.microsoft.com/en-us/powershell/module/microsoft.powershell.core/about/about_comparison_operators?view=powershell-6

© www.soinside.com 2019 - 2024. All rights reserved.