0

When exporting data to csv with Export-Csv not all data is exported because not all fields show up in Get-Member(object properties are not equal between objects). I can, however, get them out by using Select-Object.

I can build this list dynamically, but I'm unable to pass it correctly.

Example:

$test = "`"Contract`", `"Hostname`", `"Description`"" //Code generated
$selected | Select-Object $($test)

How should I do this?

2
  • Your question is a little hard to understand. You're saying piping through select object doesnt work as intended? Commented Oct 10, 2013 at 15:16
  • An example of the csv file(s), and desired output would also be very helpful. Commented Oct 10, 2013 at 15:52

1 Answer 1

1

You can pass an array of strings representing property names. For example:

$test = "Name","FullName","Length"
Get-ChildItem | Select-Object $test 
Sign up to request clarification or add additional context in comments.

1 Comment

Also: Get-ChildItem | Select-Object $("Name", "FullName", "Length")

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.