Link to home
Start Free TrialLog in
Avatar of elhjl
elhjl

asked on

Extract members from a distributiongroup and export their properties to a file.

Is it possible to extract members from a distributiongroup to a txt or xls file with all the user's properties?
If one group have 10 members, I would like to see their names, telephone numbers, email addresses, company etc.
Is there a tool that can solve this or maybe a script?
Windows 2003 server sp2 and Exchange 2003 sp2
Avatar of Brian Pierce
Brian Pierce
Flag of United Kingdom of Great Britain and Northern Ireland image

Avatar of elhjl
elhjl

ASKER

Yes I have seen that but if I understand it right by running this you will get the members but not the properties belonging to each member. What I want is to extract all members from certain distributiongroups and also get their full name, telephone number, address, email address etc.
ASKER CERTIFIED SOLUTION
Avatar of LauraEHunterMVP
LauraEHunterMVP
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 elhjl

ASKER

Ok, I don't have the possibility to try that now but I will try Adfind on Monday to see if it is the solution I'm looking for. If it is -  all the 500 points to you - LauraEHunterMVP.
You can use windows builtin tools like DSQuery and DSGet to extract such info (just in two statements)
Like:

Click Start -> Run -> Cmd.exe

DSQuery Group -Name "GroupName" -Limit 0|DSGet Group -Members >GroupMembers.txt
                                           ^---- Group Name Here

* Above statement will extract user's DN from Group and write it to 'GroupMembers.txt' file

FOR /F "delims=*" %u IN ('TYPE GroupMembers.txt') DO (DSQuery * %u -Attr Name telephoneNumber streetAddress l st postalCode co -L >>UsersInfo.txt &ECHO.>>UsersInfo.txt)

* Above loop will fetch user DN from GroupMembers.txt file and provide it to DSQuery for getting attributes value.

** This is just for your information, I have nothing to do with points. All points goes to LauraEHunterMVP
Yep, accomplishes the same result - the attribute-scoped query simply takes those multiple separate steps and smooshes them into a single operation.
Avatar of elhjl

ASKER

Hi Laura, this is exactly what I needed. I would like to do one more thing though, I need this information to a file - csv would be nice. Do you know if it possible?
Yep.  Add the -csv switch and a " > blah.csv" pipe at the end.
Avatar of elhjl

ASKER

ThankYou! Now I'm satisfied!
In powershell you could use this in the EMC PowerShell Console with ActiveDirectoy module imported:


Get-DistributionGroup "YOURDL-IN-QUOTES" | Get-DistributionGroupMember | get-user | ft


after the FT you can specify the attributes you are looking for:
Get-DistributionGroup "YOURDL-IN-QUOTES" | Get-DistributionGroupMember | get-user| ft name, phone, windowsemailaddress, company -auto


now if you want it in CSV you need to change the command since export-csv doesn't play will with FT (in my experience)
Get-DistributionGroup "YOURDL-IN-QUOTES" | Get-DistributionGroupMember | get-user | select name, phone, windowsemailaddress, company | export-csv "C:\YOURFOLDER\FILENAME.txt"