Reputation: 631
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?
Upvotes: 0
Views: 2255
Reputation: 126902
You can pass an array of strings representing property names. For example:
$test = "Name","FullName","Length"
Get-ChildItem | Select-Object $test
Upvotes: 1