[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 365
  • Last Modified:

Powershell question

hello, need assistance with the last part of this script.
basically, trying to send the results of this script to a csv:

get-qaduser -searchroot "OU=accounts,DC=domain,DC=com" -ldapfilter '(sAMAccountName)' | Format-List name,description

would like to | these results to a .csv.
i've tried adding this at the end:  | export-csv results.csv

but doesnt work.

thanks in advance,

S.
0
siber1
Asked:
siber1
1 Solution
 
wls3Commented:
As noted by Brandon in this post:

http://www.eggheadcafe.com/software/aspnet/33415041/exportcsv-issues.aspx

you should use the select instead of format cmdlet before piping to the export-csv cmdlet.  You might want to do some dry runs on the select versus the format cmdlets with gm to see what kind of differences there are in the underlying objects.

To answer your question, try this:

get-qaduser -searchroot "OU=accounts,DC=domain,DC=com" -ldapfilter '(sAMAccountName)' | Select name,description | export-csv results.csv

Open in new window

0
 
siber1Author Commented:
that did it! thanks much
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now