Exchange 2016 Recipients Filters in recipient Shell commands

 

This tutorial is going to explore on “How to use the Shell to create different types of recipient filters”.

 

You can use multiple Exchange Management Shell commands to filter a set of recipients. You are permitted to create the following types of filters in an Exchange command:

 

  • Precanned filters
  •  

  • Custom filters using the RecipientFilter parameter
  •  

  • Custom filters using the Filter parameter
  •  

  • Custom filters using the ContentFilter parameter

 

Previous versions of Exchange used LDAP filtering syntax for creating custom address lists, email address policies, global address lists (GALs), and distribution groups. In the Exchange Server 2007 and later versions, the OPATH filtering syntax replaced the LDAP filtering syntax.

 

Contents

  • Precanned filters
  •  

  • Custom filters using the RecipientFilter parameter
  •  

  • Custom filters using the Filter parameter
  •  

  • Custom filters using the ContentFilter parameter
  •  

  • Additional OPATH syntax information
  •  

  • Recipient filter documentation
  •  

  • Precanned filters

 

A precanned filter is a commonly utilized Exchange filter which you can use to address a variety of recipient-filtering criteria for duly creating dynamic distribution groups, address lists, email address policies, or GALs. By using precanned filters, you may use either the Exchange Management Shell or the Exchange Administration Center (EAC).

 

You are allowed to perform the following by using precanned filters:

 

  • Verify the scope of recipients.
  •  

  • Append conditional filtering based on properties like department, company, and state or region.
  •  

  • Append the custom attributes for recipients.
  •  

 

The following parameters are taken into the consideration for precanned filters:

 

  •  IncludedRecipients
  •  

  • ConditionalCompany
  •  

  • ConditionalDepartment
  •  

  • ConditionalStateOrProvince
  •  

  • ConditionalCustomAttribute1–15.

 

Precanned filters are present for the following cmdlets:

 

  • New-DynamicDistributionGroup
  •  

  • Set-DynamicDistributionGroup
  •  

  • New-EmailAddressPolicy
  •  

  • Set-EmailAddressPolicy
  •  

  • New-AddressList
  •  

  • Set-AddressList
  •  

  • New-GlobalAddressList
  •  

  • Set-GlobalAddressList

 

For Example

This example describes using precanned filters in the 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:

 

  • From which organizational unit (OU) you wish to include recipients? (This question corresponds to the RecipientContainer parameter.)

 

Kindly Note:

Choosing the OU for this purpose is applicable only while creating dynamic distribution groups, and not while creating address lists, email address policies, or GALs.

 

  • What kind of recipients do you wish to include? (This question is with respect to the IncludedRecipients parameter.)
  •  

  • What additional conditions do you wish to include in the filter? (This question is with respect to the ConditionalCompany,ConditionalDepartment, ConditionalStateOrProvince, and ConditionalCustomAttribute parameters.)
  •  

  • This example generates and creates the dynamic distribution group Contoso Finance for user mailboxes in the OU Contoso.com/Users and mentions 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 shows the properties of this new dynamic distribution group.

 

  • Get-DynamicDistributionGroup -Identity “Contoso Finance” | Format-List Recipient*,Included*
  •  

  • Custom filters utilizing the RecipientFilter parameter
  •  

  • In case precanned filters don’t address your requirements for creating or modifying dynamic distribution groups, email address policies, and address lists, you might create a custom filter by utilizing the RecipientFilter parameter.

 

The recipient filter parameter is present for the following cmdlets:

 

  • New-DynamicDistributionGroup
  •  

  • Set-DynamicDistributionGroup
  •  

  • New-EmailAddressPolicy
  •  

  • Set-EmailAddressPolicy
  •  

  • New-AddressList
  •  

  • Set-AddressList
  •  

  • New-GlobalAddressList
  •  

  • Set-GlobalAddressList

 

Example

  • The following given example uses the RecipientFilter parameter to create a dynamic distribution group. The syntax for this example is similar however not identical to the syntax you utilizee to create an email address policy, or GAL.
  •  

  • 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’)) }

 

Custom filters utilizing the Filter parameter

 

  • You are allowed to use the Filter parameter to filter the outcomes of a command to mention which objects to retrieve. For instance, instead of retrieving all users or groups, you may mention a set of users or groups by using a filter string. This kind of filter doesn’t modify any configuration or attributes of objects. This only modifies the set of objects which the command returns.
  •  

  • Using the Filter parameter to amend command results is called server-side filtering. The Server-side filtering gives the command and the filter to the server for processing. The Shell supports client-side filtering, in which the command retrieves all available objects from the server and then applies the filter in the local console window. For performing client-side filtering, use the Where-Object cmdlet.
  •  

  • To explore the filterable properties for cmdlets which have the Filter parameter, you may execute the Get command against an object and format the output by pipelining the Format-List parameter. Mailnlyf the returned values is going to be available for use in the Filter parameter. The following mentioned example returns a detailed list for the mailbox Ayla.
  •  

  • Get-Mailbox -Identity Ayla | Format-List

 

The Filter parameter is present for the following cmdlets

 

  • Get-ActiveSyncDevice
  •  

  • Get-ActiveSyncDeviceClass
  •  

  • Get-CASMailbox
  •  

  • Get-Contact
  •  

  • Get-DistributionGroup
  •  

  • Get-DynamicDistributionGroup
  •  

  • Get-Group
  •  

  • Get-Mailbox
  •  

  • Get-MailboxStatistics
  •  

  • Get-MailContact
  •  

  • Get-MailPublicFolder
  •  

  • Get-MailUser
  •  

  • Get-Message
  •  

  • Get-MobileDevice
  •  

  • Get-Queue
  •  

  • Get-QueueDigest
  •  

  • Get-Recipient
  •  

  • Get-RemoteMailbox
  •  

  • Get-RoleGroup
  •  

  • Get-SecurityPrincipal
  •  

  • Get-StoreUsageStatistics
  •  

  • Get-ThrottlingPolicyAssociation
  •  

  • Get-UMMailbox
  •  

  • Get-User
  •  

  • Get-UserPhoto
  •  

  • Remove-Message
  •  

  • Resume-Message
  •  

  • Resume-Queue
  •  

  • Retry-Queue
  •  

  • Suspend-Message
  •  

  • Suspend-Queue

 

Example

This example mainly utilizes the Filter parameter to return information regarding the user whose title includes the word “manager”.

 

  • Get-User -Filter {Title -like ‘Manager*’}
    Custom filters via using the ContentFilter parameter
  •  

  • You are permitted to use the ContentFilter parameter to select mention message content to export whenever using the New-MailboxExportRequest cmdlet. In case the command finds a message which contains the match to the content filter, it exports the message to a .pst file.

 

Example

This mention example creates an export request which searches Ayla’s mailbox for messages where the body includes the phrase “company prospectus”. In case that phrase is found, the command exports all messages with that mentioned phrase to a .pst file.

 

  • New-MailboxExportRequest -Mailbox Ayla -ContentFilter {Body -like “company prospectus*”}
  •  

  • Additional OPATH syntax information

 

Whenever creating your own custom filters is attempted, be aware of the following points:

 

  • Use braces { } around the entire OPATH syntax string with the Filter or RecipientFilter parameter.

 

Mention the hyphen before all operators. The most common operators consists of:

 

  • and
  •  

  • r
  •  

  • nt
  •  

  • eq (equals)
  •  

  • ne (nt equal)
  •  

  • lt (less than)
  •  

  • gt (greater than)
  •  

  • like (string cmparisn)
  •  

  • ntlike (string cmparisn)
  •  

  • Several properties for the RecipientFilter and Filter parameters accept and use wildcard characters. In case you use a wildcard character, use the likeoperator rather than of the eq operator. The like operator is utilized to find pattern matches in rich types, like strings, whereas the eq operator is used to find an exact match.
  •  

  • Execute the following commands to get information regarding the operators you might use.
  •  

  •  Help about_logical_operator
  •  

  •  Help about_comparison_operator
  •  

  • You may use most properties of recipient kinds to create filter strings.

 

Recipient filter documentation

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

Filterable properties for the -RecipientFilter parameter Explore more regarding the filterable properties for the RecipientFilter parameter.
Filterable properties for the -Filter parameter Explore more regarding the filterable properties for the Filter parameter.
Filterable properties for the -ContentFilter parameter Explore more about using the ContentFilter parameter when using the New-MailboxExportRequest cmdlet.

Kristin is a content strategist at Techarex Networks. Kristin follows the B2B technology space closely and loves to write on the latest changes in technology, futuretech and fixes for day to day how to issues. Besides writing Kristin also loves music, moves and skating.

Techarex Networks provides the complete range of Hosted Exchange solutions and services, giving access to reliable, secure, messaging and collaborative enterprise-grade solutions having 99.999% uptime with unmatched SLA. Provide enterprise-level sync with Outlook Web App and mobile devices. Anywhere, anytime access using Instant Message and video calling integration.