Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've found article at Microsoft claiming that this powershell query would give me a list of users in a dynamic distribution group that is defined more or less like this:


The code to list:

$MarketingGroup = Get-DynamicDistributionGroup "Marketing Group"
Get-Recipient -RecipientPreviewFilter $MarketingGroup.RecipientFilter -OrganizationalUnit $MarketingGroup.OrganizationalUnit

So I modified it a bit:

$members = Get-DynamicDistributionGroup -Identity "dynamic group"
Get-Recipient -RecipientPreviewFilter $members.RecipientFilter -OrganizationalUnit $members.OrganizationalUnit | select Displayname,PrimarySmtpAddress > membersall.txt

but the problem is my query (and Microsoft for that matter) takes only part of equation into consideration. It takes the radio/checkboxes choice but it seems to be skipping the Container the users are in (even thou $members.OrganizationalUnit should do the trick). It seems to return everyone with Users with Exchange mailboxes that are in the chosen container but it also takes the people which are in default Users OU.

So how to modify the query to display only the ones within the recipient container chosen without the default Users OU.

share|improve this question
up vote 3 down vote accepted

You are using the wrong property for OrganizationalUnit The following should work:

$MarketingGroup = Get-DynamicDistributionGroup "Marketing Group"
Get-Recipient -RecipientPreviewFilter $MarketingGroup.RecipientFilter -OrganizationalUnit $MarketingGroup.RecipientContainer
share|improve this answer
That's what they proposed on Microsoft website :) I'm having hard time "finding" the right keywords myself. – MadBoy Mar 16 '12 at 17:41
Well when I run that here I get the proper listing scoped to the OU defined. Are you not getting that? I'm confused – Nate Mar 16 '12 at 18:00
The .OrganizationalUnit is the location of the dynamic distribution group, not the scope you defined in the group. – Nate Mar 16 '12 at 18:02
I'm sure it will work. I'm just saying Microsoft website is wrong and that I knew i have to change the OrganizationalUnit to something and I didn't knew to what. I miss the autocomplete from Visual Studio/Resharper for this kind of thing. – MadBoy Mar 16 '12 at 18:02
I did just look on the MS page and they do have misinformation there. – Nate Mar 16 '12 at 18:04

Incase your Dynamic DL was made in Exchange 2003 or prior... or you're running a hybrid environment. Give this one-liner a crack. Note the difference is using the LDAPRecipientFilter instead of just RecipientFilter. In a 2003 environment, the plain RecipientFilter value will be null.

Get-Recipient -RecipientPReviewFilter (Get-DynamicDistributionGroup -Identity *groupname*).LDAPRecipientFilter | Select Name,PrimarySMTPAddress
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.