收件人筛选器在 Exchange 管理外壳程序命令Recipient filters in Exchange Management Shell commands

可以使用几个 Exchange 管理外壳程序命令进行筛选的收件人组。在 Exchange 命令,可以创建以下类型的筛选器:You can use several Exchange Management Shell commands to filter a set of recipients. You can create the following types of filters in an Exchange command:

  • 固有筛选器Precanned filters

  • 使用_RecipientFilter_参数的自定义筛选器Custom filters using the RecipientFilter parameter

  • 使用_筛选器_参数的自定义筛选器Custom filters using the Filter parameter

  • 使用_ContentFilter_参数的自定义筛选器Custom filters using the ContentFilter parameter

旧版本的 Exchange 使用 LDAP 筛选语法来创建自定义地址列表、 全局地址列表 (Gal)、 电子邮件地址策略,以及通讯组。在 Exchange Server 2007年和更高版本中,OPATH 筛选语法替换 LDAP 筛选语法。Older versions of Exchange used LDAP filtering syntax to create custom address lists, global address lists (GALs), email address policies, and distribution groups. In Exchange Server 2007 and later versions, OPATH filtering syntax replaced LDAP filtering syntax.

固有筛选器Precanned filters

固有筛选器是可用于满足不同的用于创建动态通讯组、 电子邮件地址策略、 地址列表或 Gal 收件人筛选条件的常用的 Exchange 筛选器。固有筛选器,您可以使用 Exchange 管理外壳或 Exchange 管理员中心 (EAC)。使用固有筛选器,可以执行以下操作:A precanned filter is a commonly used Exchange filter that you can use to meet a variety of recipient-filtering criteria for creating dynamic distribution groups, email address policies, address lists, or GALs. With precanned filters, you can use either the Exchange Management Shell or the Exchange admin center (EAC). Using precanned filters, you can do the following:

  • 确定收件人的范围。Determine the scope of recipients.

  • 根据属性(如公司、部门和国家/地区)添加有条件的筛选。Add conditional filtering based on properties such as company, department, and state or region.

  • 将收件人添加自定义属性。有关详细信息,请参阅自定义属性Add custom attributes for recipients. For more information, see Custom Attributes.

下列参数视为固有筛选器:The following parameters are considered precanned filters:

  • IncludedRecipientsIncludedRecipients

  • ConditionalCompanyConditionalCompany

  • ConditionalDepartmentConditionalDepartment

  • ConditionalStateOrProvinceConditionalStateOrProvince

  • ConditionalCustomAttribute15_到_ConditionalCustomAttribute1ConditionalCustomAttribute1 to ConditionalCustomAttribute15.

固有筛选器适用于下列 cmdlet:Precanned filters are available for the following cmdlets:

示例Example

本示例介绍如何使用 Exchange 管理外壳程序中固有筛选器创建动态通讯组。在此示例中的语法相似但不是完全相同的语法用于创建电子邮件地址策略、 地址列表或全球通讯簿。在创建固有筛选器时,您应该询问以下问题:This example describes using precanned filters in the Exchange Management Shell to create a dynamic distribution group. The syntax in this example is similar but not identical to the syntax you would use to create an email address policy, address list, or GAL. When creating a precanned filter, you should ask the following questions:

  • 要从哪个组织单位 (OU) 包括收件人?(这个问题对应于_RecipientContainer_参数)。From which organizational unit (OU) do you want to include recipients? (This question corresponds to the RecipientContainer parameter.)

Note

为此选择的 OU 仅适用于创建动态通讯组,不适用于创建电子邮件地址策略、地址列表或 GAL。Selecting the OU for this purpose applies only when creating dynamic distribution groups, and not when creating email address policies, address lists, or GALs.

  • 要包括的收件人类型?(这个问题对应于_IncludedRecipients_参数)。What type of recipients do you want to include? (This question corresponds to the IncludedRecipients parameter.)

  • 要在筛选器中包括哪些附加条件?(这个问题对应于_ConditionalCompany_、 ConditionalDepartmentConditionalStateOrProvince_和_ConditionalCustomAttribute_参数。What additional conditions do you want to include in the filter? (This question corresponds to the _ConditionalCompany, ConditionalDepartment, ConditionalStateOrProvince, and ConditionalCustomAttribute parameters.)

本示例在 OU Contoso.com/Users 中创建用户邮箱的动态通讯组 Contoso 财务并指定要包括已定义为金融和公司部门特性的收件人的条件定义为 Contoso 的特性。This example creates the dynamic distribution group Contoso Finance for user mailboxes in the OU Contoso.com/Users and specifies the condition to include only recipients who have the Department attribute defined as Finance and the Company attribute defined as Contoso.

New-DynamicDistributionGroup -Name "Contoso Finance" -OrganizationalUnit Contoso.com/Users -RecipientContainer Contoso.com/Users -IncludedRecipients MailboxUsers -ConditionalDepartment "Finance" -ConditionalCompany "Contoso"

本示例显示此新动态通讯组的属性。This example displays the properties of this new dynamic distribution group.

Get-DynamicDistributionGroup -Identity "Contoso Finance" | Format-List Recipient*,Included*

使用 RecipientFilter 参数的自定义筛选器Custom filters using the RecipientFilter parameter

如果固有筛选器不能满足您的需要创建或修改电子邮件地址策略、 动态通讯组和地址列表,可以通过使用_RecipientFilter_参数来创建自定义筛选器。If precanned filters don't meet your needs for creating or modifying dynamic distribution groups, email address policies, and address lists, you can create a custom filter by using the RecipientFilter parameter.

收件人筛选器参数适用于下列 cmdlet:The recipient filter parameter is available for the following cmdlets:

有关您可以使用_RecipientFilter_参数筛选属性的详细信息,请参阅RecipientFilter 参数的可筛选属性For more information about the filterable properties you can use with the RecipientFilter parameter, see Filterable properties for the RecipientFilter parameter.

示例Example

下面的示例使用_RecipientFilter_参数来创建动态通讯组。在此示例中的语法类似但不是完全相同的语法用于创建电子邮件地址策略、 地址列表或全球通讯簿。The following example uses the RecipientFilter parameter to create a dynamic distribution group. The syntax in this example is similar but not identical to the syntax you use to create an email address policy, address list, or GAL.

此示例使用自定义筛选器若要创建用户邮箱具有定义为 Contoso 和Office属性定义为北方建筑公司特性的动态通讯组。This example uses custom filters to create a dynamic distribution group for user mailboxes that have the Company attribute defined as Contoso and the Office attribute defined as North Building.

New-DynamicDistributionGroup -Name AllContosoNorth -OrganizationalUnit contoso.com/Users -RecipientFilter { ((RecipientType -eq 'UserMailbox') -and (Company -eq 'Contoso') -and (Office -eq 'North Building')) }

使用 Filter 参数的自定义筛选器Custom filters using the Filter parameter

筛选器_参数用于筛选结果的命令指定要检索的对象。例如,而无需检索所有用户或组,可以通过使用一个筛选器字符串指定一的组用户或组。这种类型的筛选器不会修改任何配置或对象的属性。它仅修改该命令返回的对象的集合。You can use the _Filter parameter to filter the results of a command to specify which objects to retrieve. For example, instead of retrieving all users or groups, you can specify a set of users or groups by using a filter string. This type of filter doesn't modify any configuration or attributes of objects. It only modifies the set of objects that the command returns.

使用_筛选器_参数修改的结果被称为服务器端筛选命令。服务器端筛选提交命令以及处理到服务器的筛选器。Exchange 管理外壳程序还支持客户端筛选命令从服务器中检索的所有对象,并将该筛选本地控制台窗口中。要执行客户端筛选,使用对象的位置的cmdlet。有关服务器端和客户端筛选的详细信息,请参阅"如何为筛选器数据"中使用的命令的输出Using the Filter parameter to modify command results is known as server-side filtering. Server-side filtering submits the command and the filter to the server for processing. The Exchange Management Shell also supports client-side filtering, in which the command retrieves all objects from the server and then applies the filter in the local console window. To perform client-side filtering, use the Where-Object cmdlet. For more information about server-side and client-side filtering, see "How to Filter Data" in Working with Command Output.

要筛选的属性查找具有_筛选器_参数的 cmdlet,您可以通过管道传输格式列表参数对对象和格式输出运行Get命令。大多数返回的值可用于_筛选器_参数。下面的示例返回邮箱 Ayla 的详细的列表。To find the filterable properties for cmdlets that have the Filter parameter, you can run the Get command against an object and format the output by pipelining the Format-List parameter. Most of the returned values will be available for use in the Filter parameter. The following example returns a detailed list for the mailbox Ayla.

Get-Mailbox -Identity Ayla | Format-List

筛选器_参数是可用于以下收件人 cmdlet 的:The _Filter parameter is available for the following recipient cmdlets:

有关您可以使用_筛选器_参数筛选属性的详细信息,请参阅筛选器参数的可筛选属性For more information about the filterable properties you can use with the Filter parameter, see Filterable properties for the Filter parameter.

示例Example

此示例使用_筛选器_参数返回"管理器"的用户,其标题包含该单词的信息。This example uses the Filter parameter to return information about users whose title contains the word "manager".

Get-User -Filter {Title -like 'Manager*'}

使用 ContentFilter 参数的自定义筛选器Custom filters using the ContentFilter parameter

ContentFilter_参数用于选择要导出时使用New MailboxExportRequest cmdlet 的特定邮件内容。如果该命令找到包含于内容筛选器匹配的消息,它将消息导出到.pst 文件。You can use the _ContentFilter parameter to select specific message content to export when using the New-MailboxExportRequest cmdlet. If the command finds a message that contains the match to the content filter, it exports the message to a .pst file.

示例Example

本示例创建一个导出请求,该请求在 Ayla 的邮箱中搜索正文包含短语 "company prospectus" 的邮件。如果找到此短语,则命令会将具有此短语的所有邮件导出为 .pst 文件。This example creates an export request that searches Ayla's mailbox for messages where the body contains the phrase "company prospectus". If that phrase is found, the command exports all messages with that phrase to a .pst file.

New-MailboxExportRequest -Mailbox Ayla -ContentFilter {Body -like "company prospectus*"}

有关您可以使用_ContentFilter_参数筛选属性的详细信息,请参阅ContentFilter 参数的可筛选属性For more information about the filterable properties you can use with the ContentFilter parameter, see Filterable Properties for the ContentFilter Parameter.

其他 OPATH 语法信息Additional OPATH syntax information

创建自己的自定义筛选器时,应注意以下内容:When creating your own custom filters, be aware of the following:

  • 使用大括号 {} 周围的_筛选器_或_RecipientFilter_参数与整个 OPATH 筛选器字符串。Use braces { } around the entire OPATH filter string with the Filter or RecipientFilter parameters.

  • 所有的运算符之前都要包含连字符。最常用的运算符包括:Include the hyphen before all operators. The most common operators include:

    • -和-and

    • -或-or

    • -不-not

    • -eq(等于)-eq (equals)

    • -ne(不等于)-ne (not equal)

    • -长期(小于)-lt (less than)

    • -gt(多于)-gt (greater than)

    • -像(字符串比较)-like (string comparison)

    • -notlike(字符串比较)-notlike (string comparison)

  • 许多_RecipientFilter_和_筛选器_参数的属性接受通配符。如果您使用通配符字符,而不是eq运算符使用like运算符。Like运算符用于查找模式匹配中丰富的类型,例如字符串,而eq操作符用于查找完全匹配。Many of the properties for the RecipientFilter and Filter parameters accept wildcard characters. If you use a wildcard character, use the like operator instead of the eq operator. The like operator is used to find pattern matches in rich types, such as strings, whereas the eq operator is used to find an exact match.

  • 有关运算符的详细信息,您可以使用,请参阅:For more information about operators you can use, see:

收件人筛选器文档Recipient filter documentation

下表包含一些主题的链接,这些主题可帮助您进一步了解可与 Exchange 收件人命令一起使用的可筛选属性。The following table contains links to topics that will help you learn more about the filterable properties that you can use with Exchange recipient commands.

主题Topic 说明Description
RecipientFilter 参数用于筛选属性Filterable properties for the RecipientFilter parameter 了解有关_RecipientFilter_参数的可筛选属性的详细信息。Learn more about the filterable properties for the RecipientFilter parameter.
可筛选属性筛选器参数Filterable properties for the Filter parameter 了解有关_筛选器_参数的可筛选属性的详细信息。Learn more about the filterable properties for the Filter parameter.