Quantcast
Channel: Active questions tagged powershell-3.0 - Stack Overflow
Viewing all articles
Browse latest Browse all 123

How to ensure Export-Csv is in same column order?

$
0
0

I have the following PowerShell code that imports a csv (that has 35 column) and modifies the "Account" column. It's working as expected. However, when I export, it's adding it as the first column when it should be the 7th position.

$Results = Import-Csv "$Env:FILEPATH\Metadata\Booking*.csv" | Select-Object @{Name = 'Account'; Expression = {@("A_"+$_."Account") -replace "[^0-9a-zA-z]",'_'}}, * -ExcludeProperty Account# output to (new) csv file$Results | Export-Csv -Path "$Env:FILEPATH\Metadata\Bookingtest.csv" -NoTypeInformation

Is there a way to preserve column order upon export? Thank you!


Viewing all articles
Browse latest Browse all 123

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>