get-adobject and export-csv

Topics: User Forum
May 18, 2007 at 2:07 PM
Hi All,

I'm having problems using get-adobject to get a CSV of a few particular attributes. I want a CSV of the name, sAMAccountName and employeeID attributes of all non-disabled user accounts:

get-adobject -class user | where-object {$_.userAccountControl -ne 514} | select-object name, sAMAccountName, employeeID | export-csv -path out.csv

In the CSV, I get a bunch of lines like this:

System.DirectoryServices.PropertyValueCollection,System.DirectoryServices.PropertyValueCollection,System.DirectoryServices.PropertyValueCollection

Any way I can get the actual values here? If I don't export it, the format on the screen has the values.

Thanks,
Ryan

Developer
May 18, 2007 at 3:01 PM
This should solve your problem:

 
get-adobject -class user | where-object {$_.userAccountControl -ne 514} | select-object {$_.name}, {$_.sAMAccountName}, {$_.employeeID} | export-csv -path out.csv 

You can find more info at http://mow001.blogspot.com/2006/08/powershell-and-active-directory-part-5.html.
May 18, 2007 at 3:21 PM
Excellent! Thanks!