?
Solved

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

Posted on 2007-10-05
10
Medium Priority
?
975 Views
Last Modified: 2012-08-09
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
0
Comment
Question by:elhjl
10 Comments
 
LVL 70

Expert Comment

by:KCTS
ID: 20020516
0
 

Author Comment

by:elhjl
ID: 20021077
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.
0
 
LVL 30

Accepted Solution

by:
LauraEHunterMVP earned 2000 total points
ID: 20021206
You're actually referring to an advanced type of query called an "attribute scoped query", which translates to "Give me the member attribute of Group X, and then give me information about the things (in this case, users) listed in that attribute."

The adfind tool from www.joeware.net/freetools will perform attribute-scoped queries, but it requires a specific syntax:

adfind -b <Distinguished Name of Group> -asq member <attribute1 that you want for each user> <attribute2 that you want for each user> <attribute3 that you want for each user> <etc.>
0
What is SQL Server and how does it work?

The purpose of this paper is to provide you background on SQL Server. It’s your self-study guide for learning fundamentals. It includes both the history of SQL and its technical basics. Concepts and definitions will form the solid foundation of your future DBA expertise.

 

Author Comment

by:elhjl
ID: 20021256
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.
0
 
LVL 26

Expert Comment

by:Farhan Kazi
ID: 20021343
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
0
 
LVL 30

Expert Comment

by:LauraEHunterMVP
ID: 20021484
Yep, accomplishes the same result - the attribute-scoped query simply takes those multiple separate steps and smooshes them into a single operation.
0
 

Author Comment

by:elhjl
ID: 20032664
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?
0
 
LVL 30

Expert Comment

by:LauraEHunterMVP
ID: 20032912
Yep.  Add the -csv switch and a " > blah.csv" pipe at the end.
0
 

Author Comment

by:elhjl
ID: 20033203
ThankYou! Now I'm satisfied!
0
 

Expert Comment

by:taartero
ID: 38277762
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"
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Here's a look at newsworthy articles and community happenings during the last month.
Active Directory can easily get cluttered with unused service, user and computer accounts. In this article, I will show you the way I like to implement ADCleanup..
This tutorial will walk an individual through the process of configuring their Windows Server 2012 domain controller to synchronize its time with a trusted, external resource. Use Google, Bing, or other preferred search engine to locate trusted NTP …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Suggested Courses

850 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question