none
Get the list of members in "Dynamic distribution group"

    Question

  • Hi,

    How to get the list of group members in "Dynamic Distribution Group" with their Primary smtp address.

    Senthil KR
    Wednesday, February 03, 2010 4:50 AM

Answers

  • Hi Rajnish,

    Thanks for reply.

    Need to export list of members with their primary smtp address for existing "Query based group mail id".

    I use the following shell command to export the same.

    $members = Get-DynamicDistributionGroup -Identity "dynamicgroupname"
    Get-Recipient -RecipientPreviewFilter $members.RecipientFilter > membersall.txt

    It gives me the list of members with their name. I need their email address. Please help me in this.

    where as i've tried your suggestion in ADUC. Its not listing the members. I get only empty excel sheet with columns " Name, Type & Descrption".

    Regards,

    Senthil KR
    Hi Senthil,
    Add this "| select Displayname,PrimarySmtpAddress"

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


    Frank Wang
    • Marked as answer by Senthil KR Wednesday, February 03, 2010 10:45 AM
    Wednesday, February 03, 2010 9:38 AM

All replies

  • Senthil, Try this

    This can be done from ADUC , where as you can create a query to get all the users and then from add and remove coloumn , you can add email address and then export the list to a csv file.

    If you have the Saved query folder in teh Active Directory Users and computers Snap-in then you can do this:

    1. Right-Click the folder and select New query
    2. Give it a descriptive name
    3. Click Define Query
    4. From the drop down list select Custom Search
    5. Clcik Advanced tab
    6. Paste in the following:

    (&(objectCategory=user)(memberOf=cn=Domain Admins,cn=users,dc=YourDomain,dc=local))

    You will need to change the cn=..... part to suite your groups distinguished name.

    then once you save this and get a list you can:
    7. Right-click on your query
    8. Select Export List (not Export Query definition as this just creates a backup of the query)
    9. Select from the save as type:
       Text (Comma Delimited) (*.csv)
    Which of course, opens in Excel as it is.

    Raj
    Wednesday, February 03, 2010 4:56 AM
  • Hi Rajnish,

    Thanks for reply.

    Need to export list of members with their primary smtp address for existing "Query based group mail id".

    I use the following shell command to export the same.

    $members = Get-DynamicDistributionGroup -Identity "dynamicgroupname"
    Get-Recipient -RecipientPreviewFilter $members.RecipientFilter > membersall.txt

    It gives me the list of members with their name. I need their email address. Please help me in this.

    where as i've tried your suggestion in ADUC. Its not listing the members. I get only empty excel sheet with columns " Name, Type & Descrption".

    Regards,

    Senthil KR
    Wednesday, February 03, 2010 5:44 AM
  • You need add the coloumn and then add the email addresses from there. By default it will always show the above three fields.
    Raj
    Wednesday, February 03, 2010 5:59 AM
  • How can i add the column and where?

    Senthil KR
    Wednesday, February 03, 2010 7:44 AM
  • Check this script if this helps   http://exchangepedia.com/blog/2005/09/how-to-export-all-email-addresses-from.html


    For adding email address coloumn, go to ADUC, Click on view , add/remove coloumn and then scroll down to email address and add it.
    Raj
    Wednesday, February 03, 2010 8:50 AM
  • Hi Rajnish,

    Thanks for reply.

    Need to export list of members with their primary smtp address for existing "Query based group mail id".

    I use the following shell command to export the same.

    $members = Get-DynamicDistributionGroup -Identity "dynamicgroupname"
    Get-Recipient -RecipientPreviewFilter $members.RecipientFilter > membersall.txt

    It gives me the list of members with their name. I need their email address. Please help me in this.

    where as i've tried your suggestion in ADUC. Its not listing the members. I get only empty excel sheet with columns " Name, Type & Descrption".

    Regards,

    Senthil KR
    Hi Senthil,
    Add this "| select Displayname,PrimarySmtpAddress"

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


    Frank Wang
    • Marked as answer by Senthil KR Wednesday, February 03, 2010 10:45 AM
    Wednesday, February 03, 2010 9:38 AM
  • Thanks Frank...

    Its working fine.

    Great work...


    Senthil KR
    Wednesday, February 03, 2010 10:45 AM
  • aaaarghhh.......This has been of tremendous help.Great work Frank.Wang
    Saturday, May 08, 2010 11:08 AM
  • Senthil i think you are getting full list of users in your exchange organization.... it is not filtered...check your resultset.

     

     

     

     


    sanjay
    Tuesday, July 27, 2010 1:40 AM
  • I get this error in Powershell

    Get-Recipient : Cannot validate argument on parameter 'RecipientPreviewFilter'.
     The argument is null or empty. Supply an argument that is not null or empty an
    d then try the command again.
    At line:1 char:108
    + $members = Get-DynamicDistributionGroup -Identity "GroupName" | Get-Rec
    ipient -RecipientPreviewFilter <<<<  $members.RecipientFilter > membersall.txt
        + CategoryInfo          : InvalidData: (:) [Get-Recipient], ParameterBindi
       ngValidationException
        + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Excha
       nge.Management.RecipientTasks.GetRecipient


    We have populated the members of the Distribution group using a custom attibute.

    Any idea what we might be doing wrong while running the command

    Sunday, July 24, 2011 8:32 AM
  • On Sun, 24 Jul 2011 08:32:14 +0000, Kitaab wrote:
     
    >
    >
    >I get this error in Powershell
    >
    >Get-Recipient : Cannot validate argument on parameter 'RecipientPreviewFilter'. The argument is null or empty. Supply an argument that is not null or empty an d then try the command again. At line:1 char:108 + $members = Get-DynamicDistributionGroup -Identity "GroupName" | Get-Rec ipient -RecipientPreviewFilter <<<< $members.RecipientFilter > membersall.txt + CategoryInfo : InvalidData: (:) [Get-Recipient], ParameterBindi ngValidationException + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.Excha nge.Management.RecipientTasks.GetRecipient
    >
    >We have populated the members of the Distribution group using a custom attibute.
    >
    >Any idea what we might be doing wrong while running the command
     
    You're piping the results of the get-dynamicdistributiongroup into the
    get-recipient. Then you're trying to use an undefined "$members"
    variable.
     
    Two separate statements will work:
    $members = Get-DynamicDistributionGroup -Identity "GroupName"
    Get-Recipient -RecipientPreviewFilter $members.recipientpreviewfilter
     
    If you want them on one line, separate them with a semicolon.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Sunday, July 24, 2011 4:07 PM
  • I receive the following error after running the second command:

    Get-Recipient : The argument cannot be null or empty.
    At line:1 char:38
    + Get-Recipient -RecipientPreviewFilter  <<<< $members.recipientpreviewfilter

    Any ideas?  Thanks

    Monday, July 30, 2012 2:03 PM
  • I think there was a typo in Rich's post.  Try these two commands:

    $members = Get-DynamicDistributionGroup <name>
    Get-Recipient -RecipientPreviewFilter $members.RecipientFilter
    Steve

    Monday, July 30, 2012 2:41 PM
  • I still get the same error.  I am using the following commands:

    $members = Get-DynamicDistributionGroup -Identity "<name>"
    Get-Recipient -RecipientPreviewFilter $members.RecipientFilter

    Any ideas?  Thanks

    Monday, July 30, 2012 2:48 PM
  • After running the first command, could you run the following and see what is returned:

    $members.RecipientFilter

    If you get nothing back then run this command:

    Get-DynamicDistributionGroup <name> | fl *filter

    Monday, July 30, 2012 3:06 PM
  • I have run the two commands as the first command gave no return,  The second command showed a blank value for RecipientFilter and listed a value for the LdapRecipientFilter.  I have pasted it below with some changes:

    (&(!cn=SystemMailbox{*})(&(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList) )))(objectCategory=user)(physicalDeliveryOfficeName=City, ST))))

    I want to believe to export the member list of this dynamic distribution group and also be able to add 2 members who do not fit the description of the filter.

    Any ideas?  Thanks

    Monday, July 30, 2012 3:17 PM
  • On Mon, 30 Jul 2012 14:41:34 +0000, steve siyavaya wrote:
     
    >
    >
    >I think there was a typo in Rich's post. Try these two commands: $members = Get-DynamicDistributionGroup <name>
    >Get-Recipient -RecipientPreviewFilter $members.RecipientFilterSteve
     
    Darned copy-and paste!
     
    "-RecipientPreviewFilter $members.RecipientFilter" is what it _should_
    have been. :-(
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Monday, July 30, 2012 4:16 PM
  • On Mon, 30 Jul 2012 15:17:26 +0000, jsadmin wrote:
     
    >I have run the two commands as the first command gave no return,
     
    That's not good. What do you get if you use "$members | fl"?
     
    >The second command showed a blank value for RecipientFilter and listed a value for the LdapRecipientFilter. I have pasted it below with some changes:
    >
    >(&(!cn=SystemMailbox{*})(&(&(&(& (mailnickname=*) (| (&(objectCategory=person)(objectClass=user)(!(homeMDB=*))(!(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=user)(|(homeMDB=*)(msExchHomeServerName=*)))(&(objectCategory=person)(objectClass=contact))(objectCategory=group)(objectCategory=publicFolder)(objectCategory=msExchDynamicDistributionList) )))(objectCategory=user)(physicalDeliveryOfficeName=City, ST))))
    >
    >I want to believe to export the member list of this dynamic distribution group and also be able to add 2 members who do not fit the description of the filter.
    >
    >Any ideas? Thanks
     
    How was that DDL created? If it has a LdapRecipientFilter but no
    RecipientFilter then it's probably an Exchange 2003 QBDL that needs
    attention. You should be able to set the same condition on the DDL
    with OPATH "Office='City, ST'".
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Monday, July 30, 2012 4:30 PM
  • Rich,

    Your first assumption is correct as it has a LdapRecipientfilter but no RecipientFilter.  the RecipientFilterType is set to Legacy.  How can I update this group without effecting its mail properties (i.e. Membership and e-mail address)?

    I also want to be able to add two members who do not match the filter properties?  How can I do that as well?

    Thank you.

    Monday, July 30, 2012 4:50 PM
  • On Mon, 30 Jul 2012 16:50:46 +0000, jsadmin wrote:
     
    >Your first assumption is correct as it has a LdapRecipientfilter but no RecipientFilter. the RecipientFilterType is set to Legacy. How can I update this group without effecting its mail properties (i.e. Membership and e-mail address)?
     
    The filter looks like it's supposed to include any mail- or mail-box
    enabled AD objects that have a physicalDeliveryOfficeName of "City,
    State".
     
    For example:
    Set-DynamicDistributionGroup DDL01 -RecipientFilter "Office -eq
    'Ada,OK'"
     
    >I also want to be able to add two members who do not match the filter properties? How can I do that as well?
     
    You can't. But what you *can* do is create a universal DL and add the
    DDL as a member. Then add the two other people to the DL. Hide the DDL
    from the GAL. Send the e-mail to the "regular" group.
     
    ---
    Rich Matheisen
    MCSE+I, Exchange MVP
     

    --- Rich Matheisen MCSE+I, Exchange MVP
    Monday, July 30, 2012 7:39 PM
  • Also remember the -OrganizationalUnit $members.OrganizationalUnit else you get the search from top level.
    Friday, November 23, 2012 9:15 AM
  • 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

    • Edited by Ryan Staats Saturday, January 19, 2013 12:11 AM
    Saturday, January 19, 2013 12:11 AM
  • Below command works for me

    $Users= Get-DynamicDistributionGroup -Identity "dynamicgroupname"
    Get-Recipient -RecipientPreviewFilter $Users.RecipientFilter > Memberlist.txt


    Thanks Prem P Rana MCSA Messaging 2003 MCSE 2003 Server MCTS MCITP Exchange 2007, 2010 Gurgaon, India

    Saturday, January 19, 2013 1:22 PM
  • When i tried this command it gave me a list of all my groups and email addresses. I don't think the filter is working properly.

    Chris MCP

    Tuesday, February 11, 2014 11:02 PM
  • It seems that the command

    Get-Recipient -RecipientPreviewFilter $Users.RecipientFilter

    does not work. At least in Exchange 2013 CU3.

    The command will list the recipients that match the filter, but it doesn't take into account the RecipientContainer property. Therefore, even if the command lists ten members for a DDL, those users still won't get the e-mail targeted to that DDL, because they are in a different OU that the DDL's RecipientContainer.

    So that command cannot be used to find out the members of a DDL.

    Tuesday, February 25, 2014 8:38 PM
  • Hi SKouti,

    You're right, the accepted answer doesn't take into account the ReceipientContainer property of the dynamic distribution group.  I've modified his answer below:

    $members = Get-DynamicDistributionGroup <name>
    $recipients = Get-Recipient -RecipientPreviewFilter $members.RecipientFilter
    $constrainedRecipients = @()
    foreach ($recipient in $recipients) {
        if ( $recipient.Identity.isDescendantOf( $members.RecipientContainer ) ) {
            $constrainedRecipients += $recipient
        }
    }
    $constrainedRecipients | select Displayname, Primarysmtpaddress > membersall.txt

    This seems to work on our Exchange 2010 instance.

    Best,

    Josh


    • Edited by Josh Senick Tuesday, February 25, 2014 11:36 PM Answer worked in a narrower case; this answer works in every case.
    • Proposed as answer by Josh Senick Tuesday, February 25, 2014 11:40 PM
    Tuesday, February 25, 2014 11:24 PM
  • I utilise the following:

    $Members=Get-DynamicDistributionGroup -Identity <GroupName>

    Get-Recipient -RecipientPreviewFilter $Members.RecipientFilter -OrganizationalUnit $Members.RecipientContainer | Sort-Object | Select-Object DisplayName,PrimarySMTPAddress | Export-CSV C:\Temp\Outlist.csv

    Hope this helps!

    Cheers,

    Dave

    Monday, March 17, 2014 4:04 AM
  • I also need the member list for my Dynamic Distribution Group. I ran the following:

    $Users= Get-DynamicDistributionGroup -Identity "dynamicgroupname"
    Get-Recipient -RecipientPreviewFilter $Users.RecipientFilter > Memberlist.txt

    This script exported every mailbox in AD.

    If I look in EMC for that particular DDG, it shows two mailbox (which is correct).  But if I run any of the above scripts, it pulls every single mailboxes in AD.

    My DDG is setup this way:

    Under the Filter tab - defined the OU

    Recipient Types = Users with Exchange mailboxes

    Under the Conditions tab - Custom Attribute 1 = group1

    How should I go about setting up the powershell script?

    Wednesday, April 02, 2014 9:53 PM
  • IF YOU WANT THIS TO WORK USE THIS CODE if you are on Exchange 2010 or higher. I am on 2010.

    Get-Recipient -RecipientPreviewFilter (Get-DynamicDistributionGroup -Identity "Sales").RecipientFilter | Select Name > saleslist.txt

    change sales to whatever your DDG name is and you should be fine. Txt file will be in C:\Windows\System32 folder.

    I found the correct code at this address http://deangrant.wordpress.com/2014/04/12/preview-recipients-that-are-members-of-a-dynamic-distribution-list/

     

    • Proposed as answer by Noe.O Monday, June 02, 2014 7:44 PM
    Friday, May 09, 2014 12:46 PM
  • If you have subdomains in your forest, try this first

    Set-ADServerSettings -ViewEntireForest $true

    Refer: http://technet.microsoft.com/de-DE/library/aa996367(v=exchg.150).aspx

    Regards

    Georgios


    Friday, June 27, 2014 7:54 AM
  • I would like to ask if there is a way to pull all dynamic groups, and members?  We have around 15 groups and it would be very nice if I could run the above command but have it pull all groups and all members into a list..

    Thanks, Grady Vogt

    Thursday, July 17, 2014 2:13 PM
  • Christ!!!! Why isn't there simply a "View Member List" option?  Hey MS, what are you thinking?
    Friday, August 08, 2014 3:37 PM
  • In the EMC there is. Whether or not you want to look at a list that's several thousand items in length in that way is something else. For large lists it's easier to use more appropriate tools.

    --- Rich Matheisen MCSE&I, Exchange MVP

    Saturday, August 09, 2014 9:10 PM
  • You could use something like this:

    $members = @()
    Get-DynamicDistributionGroup foreach {
    	$members += Get-Recipient -RecipientPreviewFilter $_.RecipientFilter -OrganizationalUnit $_.RecipientContainer
    }
    $members | select <list of properties | export-csv etc.


    --- Rich Matheisen MCSE&I, Exchange MVP

    Saturday, August 09, 2014 9:14 PM
  • NEW *** ADDED

    ***Export all the Distribution group and Distribution Group managers as well***

    ***Export all the Dynamic Distribution group and Distribution Group managers as well***

    Download the Automated Script -http://gallery.technet.microsoft.com/exchange/Export-all-distribution-707c27eb


    Satheshwaran Manoharan | Exchange 2003/2007/2010/2013 | Blog:http://www.careexchange.in | Please mark it as an answer if it really helps you ------------- I do not represent the organisation I work for, all the opinions expressed here are my own. This posting is provided "AS IS" with no warranties or guarantees and confers no rights.

    Thursday, August 21, 2014 8:49 AM