Dynamic Distrobution List - Target an OU

Hi Guys,

I am trying to create dynamic distribution list that does the following.

-Targets an OU

-searches for staff with a title

searching is fine but I cant seem to target the OU and still get results from other OU's when I preview the distribution list. 

New-DynamicDistributionGroup -Name "Anthony test targeted" -OrganizationalUnit "OU=users,OU=staff,DC=microsoft,DC=local" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title -like 'operations manager*' -or Title -like 'area operations Manager*') }

any help would be great cheers!

July 2nd, 2013 6:35pm

Hi Anthony,

Check out RecipientContainer:

http://technet.microsoft.com/en-us/library/bb125127%28v=exchg.141%29.aspx

An example using your code:

New-DynamicDistributionGroup -Name "Anthony test targeted" -OrganizationalUnit "OU=users,OU=staff,DC=microsoft,DC=local" -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title -like 'operations manager*' -or Title -like 'area operations Manager*') } -RecipientContainer "OU=users,OU=staff,DC=microsoft=DC=local"

-OrganizationalUnit is used to determine where to create the group, not who to include.

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 7:01pm

THANKS!! I'm new to scripting
July 2nd, 2013 8:36pm

You're very welcome, I'm glad I could help out. Here's a good link for getting started:

http://technet.microsoft.com/en-us/scriptcenter/dd793612.aspx

There's also the script repository, which has tons of example scripts to look over and modify:

http://gallery.technet.microsoft.com/scriptcenter

Lastly, here's a link to my favorite command reference site:

http://ss64.com/ps/

Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2013 8:40pm

Problems with the code?
July 2nd, 2013 10:56pm

yeah I am able to create the script but it still returns results from other OU's ,I've had a few guys look at it and even a IT service provider.

May not be the code but I'm lost

New-DynamicDistributionGroup -Name "Manager Test" -OrganizationalUnit "OU=groups,DC=microsoft,DC=local"  -RecipientContainer "OU=users,OU=staff,DC=microsoft,DC=local"  -RecipientFilter {(RecipientType -eq 'UserMailbox') -and (Title -like 'operations manager*' -or Title -like 'area operations Manager*') }

Free Windows Admin Tool Kit Click here and download it now
July 3rd, 2013 6:32pm

After testing it seems that the code was correctly targeting the OU but preview with-in exchange MMC was broken and generating recipients who would not infact be reciving the email because they weren't in the OU. More Info below Thanks again.

zerohoursleepdotcom/2010/03/bug-revealed-in-dynamic-distribution-groups-on-exchange-2007/

 
July 4th, 2013 8:34pm

Always fun to uncover a bug. Glad it all worked out.
Free Windows Admin Tool Kit Click here and download it now
July 5th, 2013 5:23pm

Hi Anthony,

I know you've already answered your question but I've uploaded a script I use to get the distribution group members from static or dynamic distribution groups here: http://gallery.technet.microsoft.com/Get-DistributionGroupMember-978af348 For dynamic groups it uses the RecipientContainer property to limit the search for recipients so you get to preview the members without the extra's the console's bug brings in.

The Exchange documentation mentions issues with custom filters and the Preview button in the Exchange Management Console and gives an example on how to use PowerShell to view the members here: http://technet.microsoft.com/en-us/library/bb232019%28EXCHG.80%29.aspx

I hope this helps,
Mark.

July 6th, 2013 4:52am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics