Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/powershell/11.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何通过PowerShell和EWS管理的API检索PR_规则_操作?_Powershell_Delegates_Exchangewebservices_Mapi_Ews Managed Api - Fatal编程技术网

如何通过PowerShell和EWS管理的API检索PR_规则_操作?

如何通过PowerShell和EWS管理的API检索PR_规则_操作?,powershell,delegates,exchangewebservices,mapi,ews-managed-api,Powershell,Delegates,Exchangewebservices,Mapi,Ews Managed Api,我需要检索和检查委托转发规则EWS中的内置委托命令不足以满足我的需要,因为它们阻塞了用作委托的组 我能够成功找到Schedule+EMS界面创建的规则。但是,我无法检索PR_规则_操作。打开跟踪 我看到PidTagRuleMsgProvider属性返回得很好,但PR_RULE_操作从未返回 我怀疑我在propertyset定义中使用了错误的MAPI属性类型,但我已经查看了中列出的所有内容。有什么线索吗 以下是相关的代码片段: # Setup Basic EWS Properties for Me

我需要检索和检查委托转发规则EWS中的内置委托命令不足以满足我的需要,因为它们阻塞了用作委托的组

我能够成功找到Schedule+EMS界面创建的规则。但是,我无法检索PR_规则_操作。打开跟踪

我看到PidTagRuleMsgProvider属性返回得很好,但PR_RULE_操作从未返回

我怀疑我在propertyset定义中使用了错误的MAPI属性类型,但我已经查看了中列出的所有内容。有什么线索吗

以下是相关的代码片段:

# Setup Basic EWS Properties for Message Search - Used to locate Hidden Forwarding Rule
$searchFilterForwardRule         = New-Object Microsoft.Exchange.WebServices.Data.SearchFilter+ContainsSubstring([Microsoft.Exchange.WebServices.Data.ItemSchema]::ItemClass, "IPM.Rule", [Microsoft.Exchange.WebServices.Data.ContainmentMode]::Prefixed, [Microsoft.Exchange.WebServices.Data.ComparisonMode]::Exact)
$itemViewForwardRule             = New-Object Microsoft.Exchange.WebServices.Data.ItemView(30, 0, [Microsoft.Exchange.Webservices.Data.OffsetBasePoint]::Beginning)
$itemViewForwardRule.PropertySet = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties, [Microsoft.Exchange.WebServices.Data.ItemSchema]::ItemClass, [Microsoft.Exchange.WebServices.Data.ItemSchema]::Subject)
$itemViewForwardRule.Traversal   = [Microsoft.Exchange.WebServices.Data.ItemTraversal]::Associated

# Properties for Hidden Delegate Forwarding Rule
$PID_TAG_RULE_MSG_PROVIDER    = New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x65EB,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::String)
$PID_TAG_RULE_ACTIONS     =  New-Object Microsoft.Exchange.WebServices.Data.ExtendedPropertyDefinition(0x6680,[Microsoft.Exchange.WebServices.Data.MapiPropertyType]::Binary)

# Property Set for Delegate Forward Rule
$propertySetForwardRule = New-Object Microsoft.Exchange.WebServices.Data.PropertySet([Microsoft.Exchange.WebServices.Data.BasePropertySet]::FirstClassProperties, $PID_TAG_RULE_MSG_PROVIDER)

$forwardRuleExists = $false

$findResults = $service.FindItems([Microsoft.Exchange.Webservices.Data.WellKnownFolderName]::Inbox, $searchFilterForwardRule, $itemViewForwardRule)


If ($findResults.TotalCount -lt 1) {
Write-Error "Failed to find rule" "Error"
} Else {
Foreach ($item in $findResults.Items) {

    $item.Load($propertySetForwardRule)


    If ($item.ExtendedProperties.Count -ge 1) {

        If ($item.ExtendedProperties[0].Value -eq "Schedule+ EMS Interface") {
            $forwardRuleExists = $true
            write-host "Delegate forwarding rule found." -ForegroundColor Cyan

            $propertySetForwardRule.Add($PID_TAG_RULE_ACTIONS)
            $item.Load($propertySetForwardRule)

            Write-Host "Attempting to retrieve x6680 PR_RULE_ACTIONS (PidTagRuleActions)" -ForegroundColor Cyan
            $PR_RULE_ACTIONS = $null 
                if($Item.TryGetProperty($Pid_Tag_Rule_Actions,[ref]$PR_RULE_ACTIONS)){  

                    return $PR_RULE_ACTIONS
                } # endif
              else {write-host "TryGetProperty for PR_RULE_ACTIONS failed!" -ForegroundColor Red 
                } # endelse


        } # End If - Correct Message 

    } # End If - Has Extended Properties
} # End ForEach            
} # End If - Message Count

PR_规则_操作的属性标记为0x668000FE。您可以在中看到它和属性数据-转到收件箱文件夹,单击IMAPIFolder按钮,转到PR_RULES_表选项卡,选择规则,双击PR_rule_ACTIONS属性。

Glen Scales能够将我设置在正确的路径上。事实证明,PR_RULE_操作不是通过EWS公开的,而是通过一个名为PR_EXTENDED_RULE_ACTIONS的属性公开的相同数据。现在我很高兴地抛出代码来解析二进制blob


是的,我在文档中找到了该属性类型。但是,在EWS托管API中指定MAPI属性类型时,我只能指定我以前引用过的URL中列出的一个值:二进制、整数、字符串、字符串数组等。它在Exchange 2013 Exchange Online环境中公开,但不在我们的内部部署Exchange 2010环境中公开。仍在试图找出原因。。。。