Weird Format-Table problem

Hello all,

I’ve googled a ton and I’m not getting any further, so time to ask for help.

Let’s say I have an object and this is the return:

PS C:UsersIAADADocuments> $variable

Name Value

a {blah, blah, blah, blah, blah, …}

b {blah, blah, blah, blah, blah, …}

c {blah, blah, blah, blah, blah, …}

I’m attempting to output columns for each name and have their values below like so:

$variable.a

————–

$variable.a[0]

$variable.a[1]

$variable.a[2]

$variable.b

————–

$variable.b[0]

$variable.b[1]

$variable.b[2]

$variable.c

————–

$variable.c[0]

$variable.c[1]

$variable.c[2]

$table = @()

ForEach($key in $variable){

For($i=0;$i -lt $key.count;$i ++){

$objPSCustom = New-Object PSObject

$objPSCustom | add-member -name “$.key” -value “$key.value[$i]”

$table += $objPSCustom

}

}

When I return $table, it only prints the data for the first key? But if I query that data directly it returns the correct information?!

PS C:UsersIAADADocuments> $table[561]

$variable.b

——————

blah

I’m at a serious loss here. Any takers?

submitted by /u/wingsndonuts
[link] [comments]

Leave a Reply