Sweet!  Works like a charm.  Thanks for the edumication!

Larry

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Monday, April 05, 2010 11:53 AM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

That's not the case here.

The easiest way to run that is to copy it to a file (copy/paste from the email 
into Notepad works fine) , give it a .ps1 extension, and the run that from the 
EMS shell.

If you saved it as get_DL_members.ps1, then open up the ESM, navigate to the 
directory where you saved it and enter

./get_DL_members.ps1

That will run the script.

From: Brown, Larry [mailto:larry.br...@dplinc.com]
Sent: Monday, April 05, 2010 10:45 AM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

I must be doing something wrong here...and that's to be expected since I'm 
pretty weak using Powershell.  But I'm trying to learn.

When I run this:
$dl_recs = @()$groups = get-distributiongroup -organizationalunit "OU/MYDLOU" 
foreach ($group in $groups){get-distributiongroupmember $group |% {$_ | 
Add-Member -MemberType NoteProperty -Name "DL" -Value $group.name $dl_recs += 
$_}}$dl_recs | select DL,Name,RecipientType | Export-Csv dl.csv -notype

I get this:
Unexpected token 'groups' in expression or statement.
At line:1 char:22
+ $dl_recs = @()$groups  <<<< = get-distributiongroup -organizationalunit 
"OU/MYDLOU" foreach ($group in $groups){get-
distributiongroupmember $group |% {$_ | Add-Member -MemberType NoteProperty -Na
me "DL" -Value $group.name $dl_recs += $_} $dl_recs | select DL,Name,RecipientT
ype | Export-Csv dl.csv -notype

Usually when Powershell commands are posted I have to pull the lines together 
in to one line, remove the email formatting. Is that not the case here?

Larry

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, April 02, 2010 3:50 PM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

No problem :)

From: KevinM [mailto:kev...@wlkmmas.org]
Sent: Friday, April 02, 2010 2:47 PM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

That is pretty much perfect!!!! Thanks Rob...

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, April 02, 2010 11:55 AM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

Try this:

$dl_recs = @()
$groups = get-distributiongroup -organizationalunit "<ou>"
foreach ($group in $groups){
get-distributiongroupmember $group |% {
$_ | Add-Member -MemberType NoteProperty -Name "DL" -Value $group.name
$dl_recs += $_
}
}
$dl_recs | select DL,Name,RecipientType | Export-Csv dl.csv -notype

From: KevinM [mailto:kev...@wlkmmas.org]
Sent: Friday, April 02, 2010 1:42 PM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

Sure.., I 'm not super picky on output.. I tried export-csv bob.csv, but that 
just returned all of the attributes of all of the users like I ran get-user

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, April 02, 2010 11:41 AM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

Csv?

From: KevinM [mailto:kev...@wlkmmas.org]                                        
              CS
Sent: Friday, April 02, 2010 1:38 PM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

DLNAME   | User NAME |RecpientType.

From: Campbell, Rob [mailto:rob_campb...@centraltechnology.net]
Sent: Friday, April 02, 2010 11:37 AM
To: MS-Exchange Admin Issues
Subject: RE: All users in all DL's in an OU

How do you want the output to look?


From: KevinM [mailto:kev...@wlkmmas.org]
Sent: Friday, April 02, 2010 1:10 PM
To: MS-Exchange Admin Issues
Subject: All users in all DL's in an OU


I've been asked to provide a customer with a list of all of the users in all of 
their DL's. I figured this would be a simple one-liner. Get all of the DL's in 
an OU, and spit out the members. I was wrong.... Has anyone out there, who 
would be willing to share, written this script all ready?



My Guess at a one-liner
======================
Get-DistributionGroup -OrganizationalUnit"rebob/bob" | 
Get-DistributionGroupMember | out-file dl.txt


The output - missing the DL - a list of users is not helpful to me
==============================================
Name                                                                            
  RecipientType
----                                                                            
               -------------
f919e368-1878-4aa0-adf8-a83635cc3031                  MailContact
ee2ea8f6-5306-4d75-866d-33431d915d27               MailContact



**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

**************************************************************************************************

Note:

The information contained in this message may be privileged and confidential and

protected from disclosure.  If the reader of this message is not the intended

recipient, or an employee or agent responsible for delivering this message to

the intended recipient, you are hereby notified that any dissemination,

distribution or copying of this communication is strictly prohibited. If you

have received this communication in error, please notify us immediately by

replying to the message and deleting it from your computer.

**************************************************************************************************

Reply via email to