Link to home
Start Free TrialLog in
Avatar of lacroix_al
lacroix_al

asked on

export exchange 2010 distribution list and members

Hi
I have a 2010 exchange server and need to export a list of the distribution groups and the members.
so something like this

Group name 1
      member 1
      Member 2
      . . .
Group name 2
   . . .

I tryed using the
get-distributiongroup | get-distributiongroupmemebers

but of course it only gave me the memebers
how do I get a list as I want above?

Thank you
AL
ASKER CERTIFIED SOLUTION
Avatar of duraswitch
duraswitch
Flag of United States of America 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
Avatar of lacroix_al
lacroix_al

ASKER

Thank you for the reply

I tryed running this in powershell
It returned an error
unexpected token 'in'

What should I do to fix this?
Any reason I should be getting this error?
Not sure.  I just copied and pasted the code directly from EE website to a different lab of mine and it worked.  My guess is something got messed up in the "($DL in $DLList)" portion of the for each loop.  Maybe paste everything into notepad and make sure there's no unexpected characters.  You could then try copying and pasting each line one at a time to see where it fails.
ok
I see what I did wrong. once I pasted the code it returned a >> and I didn't realize I had to press enter again.
the code works as designed
the issue is this writes to the screen and I need it to write to a file.
ok
so I guess I wasn't clear in my first post.
I need the export to a file so I can print it out and make notes on it
it can be txt or CSV or whatever as long as it shows all the info I need.

Can you or someone else show me how to do this?

Thank you
AL
ok
so here is what I did.
I took the script above and modified it like this

$DLList = get-distributiongroup
foreach ($DL in $DLList){
get-distributiongroup -identity $DL.identity | Out-file "c:\groups\DLLIST.txt" -append
get-distributiongroupmember -identity $DL.identity | Out-file "c:\groups\DLLIST.txt" -append
}

this worked but I wanted to see if there was a better way to do it?

Thanks
Al
Sorry I didn't get back to you sooner.  work seems to be keeping me busy.  Anyway, yes, that's exactly what I would have recommended.
is there a way to dump it into excel
I tried using the |Export-Csv <file name>.csv
but I got an error

what should that look like?