Powershell / QuestCommandLets script that would list theSAM accountname, display name, DN, description, and title then export to CSV file

Powershell / QuestCommandLets script that would list all users in a domain with the SAM accountname, display name, DN, description, and title then export to CSV file
Who is Participating?
Krzysztof PytkoConnect With a Mentor Senior Active Directory EngineerCommented:
Just use this one
Get-QADUser * -SizeLimit 0 | Select sAMAccountName,DisplayName,DN,Description,Title | Export-CSV c:\allusers.csv

Open in new window

David CarrCommented:
# Script source: www.itbigbang.com
# Description: This script will search and find all active directory users in particular domain
# How to use this script: http://www.itbigbang.com/how-to-list-all-active-directory-users-in-a-particular-domain-using-powershell/

# Create New Directory Service Object
$objDomain = New-Object System.DirectoryServices.DirectoryEntry "LDAP://dc=test,dc=com"

$Result = Get-QADUser -SearchRoot $objDomain.distinguishedName -LdapFilter "(proxyAddresses=smtp:*@test.com)" | Get-QADUser | Select Email,SamAccountName,DisplayName,Name
$Ouput = $Result.Email+","+$Result.SamAccountName+","+$Result.ProxyAddresses+","+$Result.DisplayName
$Ouput >> Output.txt
David CarrCommented:
Change Email,SamAccountName,DisplayName,Name to SAMaccountname, display name, DN, description, title  in the example I provided
Creating Active Directory Users from a Text File

If your organization has a need to mass-create AD user accounts, watch this video to see how its done without the need for scripting or other unnecessary complexities.

Sarang TinguriaSr EngineerCommented:
Chris has a great GUI tool for all theese stuffs

Cjwdev | AD Info - Active Directory Reporting www.cjwdev.co.uk/Software/ADReportingTool/Info.html


AdFind by joe but CLI
Leon FesterSenior Solutions ArchitectCommented:
dsquery user forestroot -limit 0 | dsget user -samid -display -dn -desc -title >leon.txt
Will give you the results in text format, so open in Excel and then resave as CSV.

Alternatively look at some output formating using the same dsquery commands for data extraction.
Leon FesterSenior Solutions ArchitectCommented:
Or just use CSVDE
csvde /f users.csv will export all users an all attributes to .csv format.
Open in Excel and delete the columns you don't want.

OR you can fine-tune the query to only export the fields you need:
csvde /f users.csv -r objectCategory=person -l "samaccountname, displayname, description, title"
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.

All Courses

From novice to tech pro — start learning today.