Getting users from dynamic distribution group Exchange 2007/2010

10,901

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:
10,901

Related videos on Youtube

MadBoy
Author by

MadBoy

Updated on September 18, 2022

Comments

  • MadBoy
    MadBoy 9 months

    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:

    Image

    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.

  • Rajshree Gupta
    Rajshree Gupta over 11 years
    Well when I run that here I get the proper listing scoped to the OU defined. Are you not getting that? I'm confused
  • Rajshree Gupta
    Rajshree Gupta over 11 years
    The .OrganizationalUnit is the location of the dynamic distribution group, not the scope you defined in the group.
  • MadBoy
    MadBoy over 11 years
    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.
  • Rajshree Gupta
    Rajshree Gupta over 11 years
    I did just look on the MS page and they do have misinformation there.