I'm trying to export an array but can't get all colums out if they are missing for the first record
Example code to demonstrate the problem
$MyArray = @()
for ($i=1; $i -le 10; $i++)
{
$NewRecord = New-Object psobject -Property @{Col1 = "Row$i"}
for ($t=1+$i; $t -le 25+$i; $t++)
{
$NewRecord | Add-Member NoteProperty -Name "Col$t" -Value "Blah"
}
$MyArray = $MyArray + $NewRecord
}
$MyArray | export-csv .\csv.csv -delimiter ";" -notype
File looks fine, but only print "col"s present in "row1"
$MyArray | fl * show the data is there
I could create a dummy record at index 0 with all data but that would be plain old ugly