Powershell Format-Table to CSV

98,728

You should be using the Export-Csv cmdlet instead.

$outList | Export-Csv -path c:\scripts\test.csv -NoTypeInformation

If you need only selected fields, pipe it into a Select-Object cmdlet first.

$outList | Select-Object -Property Name, Title, Department | Export-Csv -path c:\scripts\test.csv -NoTypeInformation
Share:
98,728
devfunkd
Author by

devfunkd

pro·gram·mer (n) - An organism capable of converting caffeine into code. Recommended by 4 out of 5 people that recommend things.

Updated on August 10, 2022

Comments

  • devfunkd
    devfunkd almost 2 years

    I have the following line in Powershell to output an array of data. The problem I am having is that Name,Title,Department do not go into columns. Instead I get a single column with each row in a single cell with tabs between.

    $outList | Format-Table Name,Title,Department -auto >c:\Scripts\test2.csv
    

    How can I output into columns?