Hello been write a lot of new functions lately but now i need to write output to a csv file and I can't the out-put too look right i been looking around a lot on the internet but non of the examples i have found dose what I need. Here is the code
$numColstoExport = "4" $content= @("1", "2", "3","4", "5", "6", "7") $finalhash=@() $Headers=@("Namn","Status","Net","RAM","test", "test","test") foreach ($row in $content){ $obj = new-object PSObject for ($i=0;$i -lt $numColstoExport; $i++){ $obj | add-member -membertype NoteProperty -name $Headers[$i] -value $row[$i] } $finalhash+=$obj $obj=$null } $finalhash | export-csv -Path C:\Users\sebbe\Desktop\test2.csv -NoTypeInformation
The code generate a csv but I can't get the $content to be displayes right. Everything in content is placed on separated rows for some reason. But if I add an extra row
$content= @("1", "2", "3","4", "5", "6", "7"), ("1", "2", "3","4", "5", "6", "7")
The content looks alright.
Any tips?