none
Need powershell help

    Question

  • I need a powershell command to create a dynamic distribution group from more than one OU.  

    My current DDG is looking at the company field in AD and so often, we have users in AD where this field is blank, so, I'd like to create a DDG that will send and email to all users in certain OUs.  

    Can you assist with the syntax for this sort of powershell please?

    Thanks

    Cliff

    Thursday, March 30, 2017 1:05 AM

All replies

  • You simply need to change the scope of the DG to cover the domain or forest, so that it applies to all OUs. That's done via the RecipientContainer parameter.

    If you mean including specific OUs only (as in more than one OU, and not all OUs under a domain), I don't think it's possible. You can populate some of the customattributeXX instead and use them.

    Thursday, March 30, 2017 9:11 AM
  • Correctly, the only one OU is available with RecipientContainer parameter.

    To achieve your goal, we can specify a special attribute for those user mailbox, then use this attribute to filter user and create dynamic distribution group.

    For example:
    1. Configure CustomAttribute for users in that two organization unit:
    Get-Mailbox -ResultSize unlimited | ? {$_.OrganizationalUnit -eq "contoso.com/IT" -or $_.OrganizationalUnit -eq "contoso.com/Sales"}| Set-Mailbox -CustomAttribute10 "DynamicDG1"
    2. Create Dynamic Distribution Groups based on CustomAttribute10:
    New-DynamicDistributionGroup -Name "DynamicDG1" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (CustomAttribute10 -eq "DynamicDG1")}

    Best Regards,

    Allen Wang


    Please remember to mark the replies as answers if they help.
    If you have feedback for TechNet Subscriber Support, contact tnmff@microsoft.com.

    Friday, March 31, 2017 9:37 AM
    Moderator