List a users Distribution Groups
Hi All,
I'm looking for a way to get a list of distribution groups for a specific set of users (OU) ...
Can this be done through EMS?
DSQUERY and DSGET aren't getting me what i need.
I appreciate any help.
Thanks,
August 6th, 2010 12:10am
Here is a post about the same topic...several options in it.
http://social.technet.microsoft.com/Forums/en-US/exchangesvradmin/thread/63ad55d1-1393-4533-8065-1d7cbd8657fa
http://www.tinyint.com/index.php/2009/05/24/enumerate-distribution-group-members/Tim Harrington - Catapult Systems - http://HowDoUC.blogspot.com
Free Windows Admin Tool Kit Click here and download it now
August 6th, 2010 4:32am
Thanks! Thats what i needed.
August 7th, 2010 12:34am
I pulled the following syntax from a linked post in the thread above..
get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_.name}) -contains (get-recipient admin@admin.local).name }
however, i was hoping to run this on a group of users.... either from a CSV or by specifying an Org Unit....
any ideas?
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2010 12:17am
Hi,
Get-Mailbox -OrganizationalUnit "YourOU" | Foreach{
$name = $_.Name;
get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_.name}) -contains $name }
}
OR
Get-Mailbox -OrganizationalUnit "YourOU" | Foreach{
$EmailID = $_.PrimarySmtpAddress;
get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_.PrimarySmtpAddress}) -contains $EmailID }
}
Regards,
Laeeq Qazi|Team Lead(Exchange + Sharepoint + BES + DynamicsCRM)
www.HostingController.com
August 10th, 2010 2:59pm
Hi Laeeq,
This does pretty much exactly what I need with one exception... I need the Outputted CSV to list groups for each user seperately.
For example:
User
Distribution Groups
John Doe
San Francisco
Managers
Claims
Sally Sue
Managers
Claims
Here is my syntax...
Get-Mailbox -OrganizationalUnit ExMergeNOC | Foreach{$n
ame = $_.Name; get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_.
name}) -contains $name}} | export-csv c:\distgroups.csv
Is this possible? Thanks again for all your help!
Free Windows Admin Tool Kit Click here and download it now
August 10th, 2010 5:48pm
anyone?
August 16th, 2010 6:26pm
bump for this...
is there anyway to export individual user membership lists to a common CSV?
For example:
User
Distribution Groups
John Doe
San Francisco
Managers
Claims
Sally Sue
Managers
Claims
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2010 12:10am
On Mon, 30 Aug 2010 21:10:22 +0000, DEMPC wrote:
>
>
>bump for this...
>
>
>
>is there anyway to export individual user membership lists to a common CSV?
Yes. The membership is found in the "memberof" property of each user.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
August 31st, 2010 2:56am
so what do i need to change in my syntax here?
Get-Mailbox -OrganizationalUnit ExMergeNOC | Foreach{$n
ame = $_.Name; get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_.
name}) -contains $name}} | export-csv c:\distgroups.csv
this exports all the dist groups but doesn't split them apart by user?
Thanks for the help.
Free Windows Admin Tool Kit Click here and download it now
August 31st, 2010 6:01pm
On Tue, 31 Aug 2010 15:01:08 +0000, DEMPC wrote:
>
>
>so what do i need to change in my syntax here?
>
>
>
>Get-Mailbox -OrganizationalUnit ExMergeNOC | Foreach{$n ame = $_.Name; get-distributiongroup |? {(get-distributiongroupmember $_ |% {$_. name}) -contains $name}} | export-csv c:\distgroups.csv
>
>
>
>this exports all the dist groups but doesn't split them apart by user?
This will get you all the a complete set of group memberships for each
mailbox:
get-mailbox | foreach{$x = [ADSI]("LDAP://" + $_.distinguishedname);
$mo = $x.memberof; etc. etc. etc.}
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
September 1st, 2010 3:55am
here is my new syntax:
get-mailbox -organizationalunit exmergephoenix | foreach{$x = [ADSI]("LDAP://" + $_.distinguishedname); $mo = $x.memberof; etc. etc. etc.} | export-csv c:\csv\phoenix.csv
This returns the following:
The term 'etc.' is not recognized as the name of a cmdlet, function, script fil
e, or operable program. Check the spelling of the name, or if a path was includ
ed, verify that the path is correct and try again.
Free Windows Admin Tool Kit Click here and download it now
September 1st, 2010 5:43pm
On Wed, 1 Sep 2010 14:43:41 +0000, DEMPC wrote:
>
>
>here is my new syntax:
>
>get-mailbox -organizationalunit exmergephoenix | foreach{$x = [ADSI]("LDAP://" + $_.distinguishedname); $mo = $x.memberof; etc. etc. etc.} | export-csv c:\csv\phoenix.csv
>
>
>
>This returns the following:
>
>The term 'etc.' is not recognized as the name of a cmdlet, function, script fil e, or operable program. Check the spelling of the name, or if a path was includ ed, verify that the path is correct and try again.
You realize that "etc." is a common abbreviation for "etcetera", don't
you?
http://www.thefreedictionary.com/etc.
http://www.thefreedictionary.com/etcetera
I didn't write a complete solution for you. I just demonstrated how to
get the data you asked about -- the set of groups in which the user is
a member.
---
Rich Matheisen
MCSE+I, Exchange MVP
--- Rich Matheisen MCSE+I, Exchange MVP
September 2nd, 2010 5:35am
i'm not that versed in powershell but i do have a decent education... So YES.. i know what etc means.
I simply thought you were incorporating it into your script. No need to send me multiple definition links.
Thanks for your help!
Free Windows Admin Tool Kit Click here and download it now
September 2nd, 2010 7:26pm
I've still been working on this... so far i've been able to list all the mailing groups but it does not split it apart by user.
get-mailbox -organizationalunit exmergephoenix | foreach{$x = [ADSI]("LDAP://" + $_.distinguishedname); $mo = $x.memberof; etc. etc. etc.} | export-csv c:\csv\phoenix.csv
i believe the LDAP query above returns security and mail groups whereas i just need the mail enabled ones.
Any ideas?
October 19th, 2010 1:20pm
Using Quest AD tools and the help of Shay Levy.... here you go
Import-Csv c:\csv\misc.csv | Foreach-Object{
$groups = Get-QADMemberOf -Identity $_.SamAccountName | Where-Object {$_.GroupType -eq 'distribution'} |Select-Object -Expand Name
New-Object PSObject -Property @{
UserName = $_.SamAccountName
Groups = $groups -join ';'
}
} | fl username, groups
Thanks, Shay.
Free Windows Admin Tool Kit Click here and download it now
October 27th, 2010 1:45pm