The Exchange 2007 Wiki

OPATH Syntax for Dynamic Distribution Groups

OPATH is the filtering syntax used by Monad, and is therefore the filtering syntax used by Exchange 2007. It replaces the complicated syntax of LDAP used in Exchange 2003, and will allow for filters which are easier to create and interpret. 
 

Note that dynamic distribution groups (DDG), email address policies, address lists, and global address lists all share approximately the same filtering behavior. They all share the same concept of “precanned” vs “custom” filters, the same filtering properties (“RecipientFilter”, “IncludedRecipients”, etc), and the same RecipientFilter syntax. Therefore, the examples and techniques below are equally useful for any of these other types, not just for dynamic distribution groups.

When creating dynamic distribution groups with E12 EMC GUI, you will be presented with three basic decisions used for filtering:

1)    From what OrganizationalUnit scope do I want to include recipients
2)    What sort of recipients do I want to include
3)    Are there any additional things I want to filter on


#1 corresponds to the “RecipientContainer” property in the Exchange shell. #2 corresponds to the “IncludedRecipients” property. #3 corresponds to the “Company”, “StateOrProvince”, and “Department” properties. And after you’ve created a DDG through the GUI, you can also notice that the RecipientFilterType is set to “Precanned”. These are the most simple sort of RecipientFilter that can be created, and are the only sort that can be created through the GUI. They take the values you’ve provided to IncludedRecipients, Company, StateOrProvince, and Department and turn them into a RecipientFilter automatically. We believe the filters available as Precanned cover the most common RecipientFilter cases used in Exchange 2003.
 

So, for instance in the GUI you could select to filter starting at the “Domain.com/Users” Organizational Unit, starting with all MailboxUser objects, and then filtering to include only those who have Company defined as “Microsoft”. This is a very common sort of DDG and very easy to do in the GUI.
 

It’s also very easy to do in the Exchange shell (syntax is roughly the same for New or Set):

   Set-DynamicDistributionGroup AllMicrosoft –RecipientContainer “Domain.com/Users” –IncludedRecipients MailboxUsers –Company “Microsoft”


After this command completes, you can inspect the results of the properties we care about with “Get-DynamicDistributionGroup AllMicrosoft | fl Recipient*,Included*”:
 

RecipientContainer      : Users,28b69b51-a381-4f50-bf34-a5c976b64d9e
RecipientFilter   : (((RecipientType –eq ‘MailboxUser’) –and (Company –eq ‘Microsoft’)) –and –not(Name –like ‘SystemMailbox{*’))
RecipientFilterType     : Precanned
IncludedRecipients      : MailboxUsers
 

Note that you can also see what is the equivalent LDAP filter by inspecting the LdapRecipientFilter property.
 

Now, what if you want to do something more complicated? Something that is not exposed as a filterable property in the GUI? Well, you can build a custom (ie – not precanned) filter!
 

For example, let’s say you want to use that exact same query we just constructed above, EXCEPT that you want it to be also based on a Custom Attribute value. In that case, you would need a custom filter and that means you need to use the RecipientFilter property directly:
 

   Set-DynamicDistributionGroup AllMicrosoft –RecipientFilter { (((RecipientType –eq ‘MailboxUser’) –and (Company –eq ‘Microsoft’)) –and –not(Name –like ‘SystemMailbox{*’) –and (CustomAttribute1 –eq ‘ITStaff’)) }

 

In this example, you’ve just taken the exact OPATH syntax used by the Precanned filter, and then added one extra clause onto the end for the CustomAttribute1 condition. Simple! 

So, what are some of the syntax basics to be aware of?

 - Use “-RecipientFilter {  <some filter> }”   (yes, curly braces around the filter)
 - OPATH uses “-and”, “-or”, and “-not” (yes, with leading hyphen)
 - Some other useful comparison operators: “-eq” (equals), “-ne” (not equal), “-lt” (less than), “-gt” (greater than), “-like” and “-notlike” (wildcard string compare).
 - Almost all of the properties exposed on the various recipient types are available to these custom RecipientFilters.
- List of filterable properties that can be used in the -RecipientFilter parameter for Exchange 2007 RTM and SP1

And finally, a really useful book (which has a great appendix with all of the available comparison operators in various tables) is the OReilly “Monad” book: http://www.oreilly.com/catalog/msh/index.html

Site

Changes
Index
Search

 

User

 

Log In
Register

 
 

Last Modified 5/6/08 7:47 AM