Editing Dynamic Distribution Group Memebership

Nico Kelly 21 Reputation points
2022-07-27T16:16:41.9+00:00

Hi there, i am relatively new to Powershell, i have been to give a client access to 2 Dynamic Distribution Groups, currently the groups are distributed using the users Department or Job Title in Active Directory

the code im trying to use is this

set-DynamicDistributionGroup -identity "Blackwood Glasgow Services West" -RecipientFilter ((((((RecipientType -eq 'UserMailbox') -and (Department -eq 'Glasgow Services') -or ((Department -eq 'Belses Care Home') -and (Title -eq 'Care Services Manager')) -and (company -eq 'Blackwood'))))))  

So basically i want this group to be distributed to people with the Department Glasgow Services OR the Department Belses Care Home and Job title of Care Services Manager.

Exchange | Exchange Server | Management
Windows for business | Windows Server | User experience | PowerShell
{count} votes

Accepted answer
  1. KyleXu-MSFT 26,396 Reputation points
    2022-07-29T06:05:07.767+00:00

    @Nico Kelly

    Try with this filter:

    -RecipientFilter "(((Department -eq 'Glasgow Services') -or (Department -eq 'Belses Care Home')) -and (Title -eq 'Care Services Manager') -and (company -eq 'Blackwood'))"  
    

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.



2 additional answers

Sort by: Most helpful
  1. Dillon Silzer 57,831 Reputation points Volunteer Moderator
    2022-07-27T16:27:19.14+00:00

    set-DynamicDistributionGroup -identity "Blackwood Glasgow Services West" -IncludedRecipients MailboxUsers -RecipientFilter ((((Department -eq 'Glasgow Services') -or (Department -eq 'Belses Care Home')) -and (Title -eq 'Care Services Manager')) -and (company -eq 'Blackwood'))

    This should work for setting your dynamic distribution group.

    Blackwood Glasgow Services West > MailboxUsers

    Department = Glasgow Services (or) Belses Care Home
    AND
    Title = Care Services Manager
    AND
    Company = Blackwood

    ---------------------------

    If this is helpful please mark as correct answer.

    0 comments No comments

  2. Nico Kelly 21 Reputation points
    2022-07-28T08:51:32.433+00:00

    @Dillon Silzer

    Unfortunentely this doesnt seem to work, i get the same error with the code i put down

    Department : The term 'Department' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.  
    At line:1 char:128  
    + ... cludedRecipients MailboxUsers -RecipientFilter ((((Department -eq 'Gl ...  
    +                                                        ~~~~~~~~~~  
        + CategoryInfo          : ObjectNotFound: (Department:String) [], CommandNotFoundException  
        + FullyQualifiedErrorId : CommandNotFoundException  
    
    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.