Dynamic Distribution Groups allow dynamic membership of distribution lists, without the need for manual oversight of membership.  This ensures your group is always up to date, provided you are updating the necessary information to qualify membership.


Using the example below, we're creating a dyn. dist. group, searching the Active Directory "location" field for:


  • New York
  • Cincinnati
  • Los Angeles


and the "department" field for:


  • IT
  • National


or a custom attribute field value:

  • aruba


You can substitute the group name with whatever name you'd like to use for testing purposes.  Do NOT use this on a live group until you fully understand how the feature is intended to work.


New-DynamicDistributionGroup -Name TestDynamicDistGroup001 -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (City -eq 'New York' -or City -eq 'Cincinnati' -or City -eq 'Los Angeles') -and (Department -eq 'National' -or Department -eq 'IT' -or CustomAttribute1 -eq 'aruba')}


Logic breakdown:


Create a new dynamic distribution group named TestDynamicDistGroup001


New-DynamicDistributionGroup -Name TestDynamicDistGroup001


use this recipient filter to determine who is a member of this group


-recipientfilter

The type of recipient is a user mailbox


{(RecipientType -eq 'UserMailbox')

AND the City field contains 'New York or 'Cincinnati' or 'Los Angeles'


-and (City -eq 'New York' -or City -eq 'Cincinnati' -or City -eq 'Los Angeles')

AND Department field contains 'National' or 'IT'


-and (Department -eq 'National' -or Department -eq 'IT'

OR Department field contains CustomAttribute1 field 'Aruba'


-or CustomAttribute1 -eq 'aruba')}



Custom attributes are set either in Exchange Management Console (on premises, not Exchange Online), or in ADUC/ADAC:



You can check what users matched your dynamic group, using the below information.


Declare variable, based on the dynamic distribution group you want to check.  $variablename can be anything you like:


$testgroup001 = Get-DynamicDistributionGroup -Identity 'TestDynamicDistGroup001'


Use variable to lookup members of distribution group | show by display name, primary email address, and additional notes on account:


Get-Recipient -recipientPreviewFilter ($testgroup001.RecipientFilter) | Select DisplayName,PrimarySmtpAddress,Notes