This is my code :
$a = @()
for ($i = 0; $i -lt 5; $i++)
{
$item = New-Object PSObject
$item | Add-Member -type NoteProperty -Name 'Col1' -Value 'data1'
$item | Add-Member -type NoteProperty -Name 'Col2' -Value 'data2'
$item | Add-Member -type NoteProperty -Name 'Col3' -Value 'data3'
$item | Add-Member -type NoteProperty -Name 'Col4' -Value 'data4'
$a += $item
}
With this code I'm able to have a result like this:
Col1 Col2 Col3 Col4
---- ---- ---- ----
0 1 2 3
1 2 3 4
2 3 4 5
3 4 5 6
4 5 6 7
Well, it's good, but how to achieve it more simply and more proper? Is there a way to create Array PsObject
maybe?
I'm using Powershell v4
.