Quantcast
Channel: The Official Scripting Guys Forum! forum
Viewing all articles
Browse latest Browse all 15028

PowerShell - Easy way to output an array to CSV text file?

$
0
0
[array]$testArray = ,("one", "two", "three")
$testArray += ,("1", "2", "3")
Write-Host "testArray -" $testArray
$testArray | Export-Csv "C:\test.csv"

Why does the test.csv file show these results:

 

#TYPE System.String
Length
1
1
1

 

It displays the strings on the console:

 

testArray - one two three 1 2 3
I've searched the net but all the solutions seem to require lots of complex code to make this happen. With so many things being so easy to do in PowerShell, I don't understand why this is so complicated.

 


Viewing all articles
Browse latest Browse all 15028

Latest Images

Trending Articles



Latest Images

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