Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to export a list of some user information from Active Directory 2003 using Powershell.

So far, I'm able to display the specific list of properties using something like this:

if ( (Get-PSSnapin -Name Quest.ActiveRoles.ADManagement -ErrorAction SilentlyContinue) -eq $null )
    Add-PsSnapin Quest.ActiveRoles.ADManagement

get-qaduser -company "Company","Consultant" `
    -enabled -DontUseDefaultIncludedProperties -IncludedProperties 'givenName','sn','telephoneNumber','mail','company' `
    | sort-object `
    | format-table givenname,sn,company,telephonenumber,mail `

However, if I try to pipe the output to export-csv, instead of format-table, I get all the properties of each domain object.

If I do something like the following:

    | format-table givenname,sn,company,telephonenumber,mail `
    | export-csv -Delimiter `t -NoTypeInformation -Path c:\scripts\adexport.csv

I get a correct number of rows with no data, except some identifier (which makes sense - since the object isn't being passed into export-csv, just a line of text).

How can I export the specific fields to a file?

I am using Quest's ActiveDirectory powershell CMDLETs ( to get the data from AD.

share|improve this question
up vote 7 down vote accepted

You want to use the Select-Object cmdlet in place of Format-Table. This should work for you:

| select-object givenname,sn,company,telephonenumber,mail `
| export-csv -Delimiter `t -NoTypeInformation -Path c:\scripts\adexport.csv
share|improve this answer
Awesome! Thanks so much! – Tim Jun 4 '10 at 20:46

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.