I have a problem with my code, when I export in the file only one object is displayed in the file, an example should be better:
There is the result :
Field1 Test1
And I want to get this :
Field1 col1 col2 Field2 col3 col4 Test1 a b Test2 c d a2 b2 c2 d2
The file :
col1 col2 a b a2 b2
I've tried my best to produce a piece of code, hope this will help. I create the field in the code.
$csv = Import-Csv .\file.csv -Delimiter ';'
$dataTable = New-Object System.Data.DataTable
$dataTable.Columns.Add("Field1") | Out-Null
foreach ($s in "Test1")
{
$row = $dataTable.NewRow()
$row["Field1"] = $s
$dataTable.Rows.Add($row)
}
#my problem is there, I don't know how merge these two lines
$dataTable | export-csv -NoTypeInformation -Path ".\fileResult.csv"
$csv | Export-CSV -Path ".\fileResult.csv" -NoTypeInformation -Delimiter ";" -Append