Link to home
Start Free TrialLog in
Avatar of Jerry Seinfield
Jerry SeinfieldFlag for United States of America

asked on

Global DL report

Hello Experts,

Can anyone please provide me with a power Shell cmdlet or script to get the list of all the DLs, the owner and members in Exchange 2010?

Any ideas would be really appreciated
Avatar of Jerry Seinfield
Jerry Seinfield
Flag of United States of America image

ASKER

I need that information exported a CSV file, or spreadsheet

Thanks
Get-DistributionGroup -ResultSize Unlimited | ft displayname,alias,primarysmtpaddress,managedby | export-csv C:\temp'test.csv

Open in new window

Avatar of SubSun
I am not sure what report format you require.. try this code and see if it works for you..
Get-DistributionGroup -ResultSize Unlimited | Select Name,`
	@{N="Owners";E={($_.ManagedBy | %{($_ -split "/")[-1]}) -join "`n"}},`
	@{N="Members";E={($_ | Get-DistributionGroupMember | Select -ExpandProperty Name) -join "`n"}} |
Export-Csv C:\report.csv -NTI

Open in new window

Hi Subsun,

I ran your script, but the csv file did not return any information, please see attached file

Any ideas?
report.csv
If your test group has members and ManagedBy properties then the possible reason would be the known pipeline bug for EMS..
I have modified the code a bit.. try it and see if you get the desired result..
$(Foreach ($Group in Get-DistributionGroup -ResultSize Unlimited) {
$Group | Select Name,`
	@{N="Owners";E={($_.ManagedBy | %{($_ -split "/")[-1]}) -join "`n"}},`
	@{N="Members";E={($_ | Get-DistributionGroupMember | Select -ExpandProperty Name) -join "`n"}}
})| Export-Csv C:\report.csv -NTI

Open in new window

Hi Subsun,

The script above did the trick, however it only returned one member and not the multiple members of each DL.

In addition to that, please see error in the attached file below
GlobalDLReportError.jpg
It should be.. just expand the row height in excel and see..

Distribution list inconsistent means there could be some issues with the DL alias..
I did expand the row height in excel same results, only one member of each DL is showed

Any ideas?

Did you check latest jpg file attached above?
This is what I get when I test the script..
User generated image
Regarding the warnings.. :

As I said Distribution list inconsistent means there could be some issues with the DL alias.. You need to check if there any illegal characters or trailing space in the DL alias..

Try this code to get rid of the result size limit warning..
$(Foreach ($Group in Get-DistributionGroup -ResultSize Unlimited) {
$Group | Select Name,`
	@{N="Owners";E={($_.ManagedBy | %{($_ -split "/")[-1]}) -join "`n"}},`
	@{N="Members";E={($_ | Get-DistributionGroupMember -ResultSize Unlimited | Select -ExpandProperty Name) -join "`n"}}
})| Export-Csv C:\report.csv -NTI

Open in new window

Hi Subsun

I tried your script above, and got same results [only one member is displayed]

btw, The Alias for all DLs start with the #. This was a client decision, therefore I cannot change the alias for 1500 Dls

Any other ideas in why is not returning all member of each DLs on column C?
Sorry I am not able to recreate the issue.. as shown in previous post I am able to see all members in report..

Are you getting the members when you run the following command?
(Get-DistributionGroupMember testGroup | Select -ExpandProperty Name) -join "`n"

Open in new window

I am unable to run the cmdlet above either from EMS or Windows powershell modules. Please see attached file

As I explained earlier, the alias of each DL starts with #

Any other ideas?
Error2.jpg
Enter the group name in quotes..
"#testGroup"


(Get-DistributionGroupMember "#testGroup" | Select -ExpandProperty Name) -join "`n"
                                            

Open in new window

Thanks Subsun,

Still unable to run the command. 1st intent, is unable to locate a domain controller on the domain, second one found an error. Please see attached jpg file
Error3.jpg
Are you sure you are entering the correct alias?

Or if you have multiple domains in forest? Then run

Set-ADServerSettings -ViewEntireForest:$TRUE
(Get-DistributionGroupMember "#testGroup" | Select -ExpandProperty Name) -join "`n"

Open in new window

Ok,

I was able to see all members of one DL by using the 2 commands above, so, What could be wrong with the script that is only returning oe member?
SOLUTION
Avatar of SubSun
SubSun
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
no luck, same results as per latest test, only one member is returned

Please see attached file
error4.jpg
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
You rock

Changing the line 5 did the trick

Many thanks for all the help
Good.. Not sure how the old code was not working for you while both the codes are working for me.. :-)