$contact = get-contact "foo@somedomain.com"; get-distributiongroup | foreach
{$dg = $_ ; get-distributiongroupmember $dg | foreach {if
($_.identity -like $contact.identity) {"Member of " + $dg} } }
There's likely a shorter way to do this...

Signature
Bharat Suneja
Microsoft Corporation
blog: exchangepedia.com/blog
This posting is provided "AS IS" with no warranties, and confers no
rights. Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
----------------------------
> Can someone tell me the best way to determine what Distribution List a
> contact object is member of?
>
> Thanks
JF - 11 Jul 2008 14:57 GMT
Thanks for the fast reply!
I ran that script and it was asking for more input. I repleace
foo@somedomain.com with my user. Is there something more I must input? It was
asking for input at process 1 and 2.
[PS] C:\Documents and Settings\adam>$contact = get-contact "she@go
.com"; get-distributiongroup | foreach
cmdlet foreach at command pipeline position 2
Supply values for the following parameters:
Process[0]: {$dg = $_ ; get-distributiongroupmember $dg | foreach {if
Process[1]: ($_.identity -like $contact.identity) {"Member of " + $dg} } }
Process[2]:
ForEach-Object : Cannot bind parameter 'Process'. Cannot convert value "{$dg =
$_ ; get-distributiongroupmember $dg | foreach {if " to type
"System.Managemen
t.Automation.ScriptBlock". Error: "Invalid cast from 'System.String' to
'System
.Management.Automation.ScriptBlock'."
At line:1 char:76
+ $contact = get-contact "she@go.com"; get-distributiongroup | foreach
<<<<
> $contact = get-contact "foo@somedomain.com"; get-distributiongroup | foreach
> {$dg = $_ ; get-distributiongroupmember $dg | foreach {if
[quoted text clipped - 6 lines]
> >
> > Thanks
Bharat Suneja [MSFT] - 11 Jul 2008 20:04 GMT
Tested this again - works for me. Not sure about the errors.
This is exactly how my query is constructed/typed (all on one line):
$contact = get-contact "foo@somedomain.com"; Get-DistributionGroup | foreach
{$dg = $_ ; Get-DistributionGroupMember $dg | foreach {if ($_.identity -like
$contact.identity) {"Member of : " + $dg} }}

Signature
Bharat Suneja
Microsoft Corporation
blog: exchangepedia.com/blog
This posting is provided "AS IS" with no warranties, and confers no
rights. Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
----------------------------
> Thanks for the fast reply!
> I ran that script and it was asking for more input. I repleace
[quoted text clipped - 32 lines]
>> >
>> > Thanks
Bharat Suneja [MSFT] - 11 Jul 2008 20:35 GMT
Taking a second look - don't think you typed it all on a single line. If you
snip the command at foreach, it'll ask you for additional input (the
process[0], process[1] etc.).

Signature
Bharat Suneja
Microsoft Corporation
blog: exchangepedia.com/blog
This posting is provided "AS IS" with no warranties, and confers no
rights. Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
----------------------------
> Tested this again - works for me. Not sure about the errors.
> This is exactly how my query is constructed/typed (all on one line):
[quoted text clipped - 39 lines]
>>> >
>>> > Thanks
JF - 12 Jul 2008 03:36 GMT
Thank you very much!
I retyped it in and all is well!
> $contact = get-contact "foo@somedomain.com"; get-distributiongroup | foreach
> {$dg = $_ ; get-distributiongroupmember $dg | foreach {if
[quoted text clipped - 6 lines]
> >
> > Thanks
Bharat Suneja [MSFT] - 20 Jul 2008 19:53 GMT
The script (with some enhancements) is available here. You can provide one
or more recipients as command-line input and get a list of groups the
recipient is a member of.

Signature
Bharat Suneja
Microsoft Corporation
blog: exchangepedia.com/blog
This posting is provided "AS IS" with no warranties, and confers no
rights. Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
----------------------------
> Thank you very much!
> I retyped it in and all is well!
[quoted text clipped - 10 lines]
>> >
>> > Thanks
Bharat Suneja [MSFT] - 20 Jul 2008 19:54 GMT
Prev message got sent without the link:
The script (with some enhancements) is available here. You can provide one
or more recipients as command-line input and get a list of groups the
recipient is a member of.
Script: Listing Distribution Groups a recipient is a member of
http://exchangepedia.com/blog/2008/07/script-listing-distribution-groups.html

Signature
Bharat Suneja
Microsoft Corporation
blog: exchangepedia.com/blog
This posting is provided "AS IS" with no warranties, and confers no
rights. Please do not send email directly to this alias. This alias is for
newsgroup purposes only.
----------------------------
> Thank you very much!
> I retyped it in and all is well!
[quoted text clipped - 10 lines]
>> >
>> > Thanks