0

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 (http://www.quest.com/powershell/activeroles-server.aspx) to get the data from AD.

1 Answer 1

8

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 
0

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.