收件者篩選在 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

  • 使用_Filter_參數的自訂篩選Custom filters using the Filter parameter

  • 使用_ContentFilter_參數的自訂篩選Custom filters using the ContentFilter parameter

舊版 Exchange 用來建立自訂通訊清單、 全域通訊清單 (Gal)、 電子郵件地址原則及通訊群組的 LDAP 篩選語法。在 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

預先定義篩選器是最常使用的 Exchange 篩選器,您可以使用以符合各種收件者篩選準則來建立動態通訊群組、 電子郵件地址原則、 地址清單或 Gal。使用預先定義篩選器,您可以使用 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 管理命令介面來建立動態通訊群組預先定義篩選器。在此範例的語法會類似,但不是相同的語法您可以使用建立電子郵件地址原則、 地址] 清單中或 GAL。建立時的預先定義篩選器,您應該提出下列問題: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.)

本範例會建立使用者信箱的動態通訊群組 Contoso Finance OU Contoso.com/Users 中並指定條件包括只有收件者已定義為財務和公司部門屬性定義為 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_參數可篩選屬性的詳細資訊,請參閱Filterable properties for RecipientFilter 參數For more information about the filterable properties you can use with the RecipientFilter parameter, see Filterable properties for the RecipientFilter parameter.

範例Example

下列範例會使用_RecipientFilter_參數來建立動態通訊群組。在此範例的語法會類似,但您用以建立電子郵件地址原則、 地址] 清單中或 GAL 語法不相同。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

您可以使用_Filter_參數來篩選結果的命令,以指定要擷取的物件。例如,不會擷取所有的使用者或群組,您可以使用篩選字串指定一組使用者或群組。這種類型的篩選器不修改任何組態或物件的屬性。它只會修改一組的命令會傳回的物件。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.

若要修改結果就所謂的伺服器端篩選的命令使用_Filter_參數。伺服器端篩選送出命令並處理伺服器的篩選器。Exchange 管理命令介面也支援用戶端篩選的命令會擷取所有物件從伺服器並再適用於本機主控台視窗中的所有篩選。若要執行用戶端篩選,使用Where-object指令程式。如需伺服器端及用戶端篩選的詳細資訊,請參閱 「 方式來篩選資料 」 在Working with Command OutputUsing 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.

若要找出具有_Filter_參數的 cmdlet 可篩選的內容,您可以針對物件及格式輸出執行Get命令透過管線傳送Format-list參數。大部分的傳回值可供使用_Filter_參數。下列範例會傳回 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

Filter_參數會提供下列收件者 cmdlet:The _Filter parameter is available for the following recipient cmdlets:

如需可篩選屬性可以搭配_Filter_參數的詳細資訊,請參閱Filterable properties for Filter 參數For more information about the filterable properties you can use with the Filter parameter, see Filterable properties for the Filter parameter.

範例Example

本範例會使用_Filter_參數來傳回其標題包含單字的使用者資訊"manager"。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指令程式時。如果此命令會找出包含的內容篩選器來比對的訊息,它會匯出至.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 的信箱郵件內文所在包含詞語匯出要求"公司 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_參數的詳細資訊,請參閱Filterable Properties 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:

  • 使用在大括號 {} 周圍整個 OPATH 篩選字串以_篩選_] 或 [ RecipientFilter_參數。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(小於)-lt (less than)

    • -gt(大於)-gt (greater than)

    • -like(字串比較)-like (string comparison)

    • -notlike(字串比較)-notlike (string comparison)

  • 許多屬性_RecipientFilter_和_Filter_參數接受萬用字元。如果您使用萬用字元,請使用like運算子,而非eq運算子。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.
Filter 參數的可篩選內容Filterable properties for the Filter parameter 深入了解的_Filter_參數可篩選的內容。Learn more about the filterable properties for the Filter parameter.