Reputation: 454
I am exporting data to a csv and for some reason the @{} are transferring over. Here is a sample script.
Get-VM VM | Select Name, @{N="DSFree";E={$_ | Get-Datastore | Select FreeSpaceMB }} | Export-Csv c:\temp\info.csv
The output of the DSFree column looks like this: @{FreeSpaceMB=686704}
How can I stop the @{} from exporting?
Thanks in advance.
Upvotes: 4
Views: 1066
Reputation: 301147
While @EBGreen's answer made me learn something, there is an easier way I believe in this case:
Get-VM VM | Select Name, @{N="DSFree";E={($_ | Get-Datastore).FreeSpaceMB }} | Export-Csv c:\temp\info.csv
Upvotes: 1
Reputation: 37730
I can't try your specific example, but typically -ExpandProperty is the answer:
Get-VM VM | Select Name, @{N="DSFree";E={$_ | Get-Datastore | Select -expandProperty FreeSpaceMB }} | Export-Csv c:\temp\info.csv
Upvotes: 3