Getting info from AD with powershell

How would I get First, Last Name, Telephone and only from specific OUs and outputting to a CSV or TXT File.. using powershell. Not sure if it can be done alphabetically but that would be a plus.
LVL 2
stlhostAsked:
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.

Vaseem MohammedCommented:
You can use Quest AD Management snapin.

Download from http://www.quest.com/powershell/activeroles-server.aspx
.Net 3 is requirement.
If you are using windows server 2012
use Add-WindowsFeature net-framework-core -Source D:\sources\sxs
where D:\sources\sxs is the path of windows 2012 dvd.

Next, Install Quest Management.
After installation is complete, run Add-PSSnapin quest.activeroles.admanagement

Finally your required 1 liner.
Get-QADUser -SearchRoot "OU=vhlusers,DC=vhl,DC=com" -IncludeAllProperties | select FirstName, LastName, PhoneNumber

this will display the result in powershell, to export it to csv you can pipe it to export-csv cmdlet.

Get-QADUser -SearchRoot "OU=vhlusers,DC=vhl,DC=com" -IncludeAllProperties | select FirstName, LastName, PhoneNumber | Export-Csv -Path c:\userdetails.csv -noTypeInformation
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
Vaseem MohammedCommented:
Oh, for sorting the results
Get-QADUser -SearchRoot "OU=vhlusers,DC=vhl,DC=com" -IncludeAllProperties | select FirstName, LastName, PhoneNumber | Sort-Object -Property LastName | Export-Csv -Path c:\userdetails.csv -NoTypeInformation

Please Note: -searchroot will be the distinguished Name of OU which contains all the target users.
0
Mohammed KhawajaManager - Infrastructure:  Information TechnologyCommented:
You could also use LDIF command included on DC.
0
stlhostAuthor Commented:
Perfect
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
Windows Server 2008

From novice to tech pro — start learning today.