I'm trying to create a custom table, i.e. I want to decide the number of columns, give titles to the columns, add rows of data and then be able to query it. For example, to get the third row I could do "$table[2]". Or to get the value of just the "CPU" column of the third row I could do "$table[2].cpu".
I know I can use hash tables to effectively create a two column table. But I'm getting stuck down the google hole trying to figure out how to make bigger tables than that.
For example, I can do this...
...which works perfectly for that one row. But how do I add another row?
Or is there a better way to do it?
I know I can use hash tables to effectively create a two column table. But I'm getting stuck down the google hole trying to figure out how to make bigger tables than that.
For example, I can do this...
Code:
$obj2 = New-Object -TypeName PSObject -Property @{
Item = "Apple"
Color = "Red"
Size = "Large"
}
$obj2 | ft
Color Item Size
----- ---- ----
Red Apple Large
Or is there a better way to do it?
Users\XXX> $Array_of_new_objects = @()