Export AD attributes from Distribution List

I have a need to export AD attributes such as Name, email, employee ID, phone#. location .... etc from a Distribution List. What's the best way to do this?
CiscoAznAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Will SzymkowskiSenior Solution ArchitectCommented:
Use the following command below to accomplish this.

$Users = Get-ADGroupMember -Identity <groupname>
ForEach ($User in $Users) {
Get-ADUser -Identity $User.sAMAccountName -Properties Name, mail, EmployeeID, OfficePhone,l | select Name, mail, EmployeeID, OfficePhone,l
}

Open in new window


That should do it.

Will.
0
arnoldCommented:
If this is an exchange data, best way is ...
you could use powershell commandlets.
You could use vbscript.

A search for "retrieve information about distribution group members" will point to several options one of which refers to a competing site, but includes the following powershell cmdlet:
Get-DistributionGroup to get a list of distribution groups.

Get-DistributionGroup -identity "group of interest to you"
Get-DistributionGroupMember  is a cmdlet to list the members of a group.

https://technet.microsoft.com/en-us/library/bb124755%28v=exchg.150%29.aspx
https://technet.microsoft.com/en-us/library/aa996367%28v=exchg.150%29.aspx

I think the information you are looking for might not be where you think it is .
i.e. you might have to use the above to identify the users that are members of the distribution group and then pass them into a dsquery|dsget to extract the complete information.

I.e. not sure employee number is stored within the exchange section of the user schema. The phone number .........
0
Steve WhitcherSystems AdministratorCommented:
Using Powershell, either on a DC or a workstation with the RSAT tools installed:
import-module activedirectory
$Members = get-adgroupmember "GROUP NAME" - recursive
$Members | get-aduser -properties * | select -property Name,EmailAddress,EmployeeNumber,TelephoneNumber,Office

Open in new window


You can add or change the properties listed after the select statement to get exactly the info you want.

Edit: Oops, I guess I took too long and didn't refresh the page before posting.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

CiscoAznAuthor Commented:
This is not an AD group but an Email Distribution List that I need to export from.
0
Steve WhitcherSystems AdministratorCommented:
An AD group can be either "security" or "distribution" type, I assumed you meant a distribution group, which work like a sort of mailing list in exchange.  If that's not right, what sort of email distribution list are you talking about?
0
Will SzymkowskiSenior Solution ArchitectCommented:
I have modified my origainal script.
Import-Module activedirectory
$Users = GetDistributionGroupMember -Identity <groupname>
ForEach ($User in $Users) {
Get-ADUser -Identity $User.sAMAccountName -Properties Name, mail, EmployeeID, OfficePhone,l | select Name, mail, EmployeeID, OfficePhone,l
}

Open in new window


I also wanted to note that Get-DistributionGroupMember is part of the Exchange cmdlets. So you need to run this directly from the Exchange Mangement Shell.

If you are running it from a regular powershell session you need to add the appropriate snapin based on your Exchange Server Version.

Will.
0
CiscoAznAuthor Commented:
Will I tried your script and it didn't work. I tried Steve's script and it worked perfectly. Thanks.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.