When you foreach through a hash you need to either foreach throught he keys
or the values.
foreach($b in $a.keys){}
or
foreach($b in $a.values){}
Brandon Shell
---------------
Blog:
http://www.bsonposh.com/
PSH Scripts Project:
www.codeplex.com/psobject
A> Hi All
A>
A> I'm struggling with something that seems simple, so what am I
A> missing?
A>
A> I want to have an array (or hash) of hashtables, then to foreach
A> through the array and pull out information. Here's an example:
A>
A> $a = @{}
A> $a[1] = @{field1="a";field2="b"}
A> $a[2] = @{field1="c";field2="d"}
A> $a[3] = @{field1="e";field2="f"}
A> I want to be able to:
A>
A> foreach ($b in $a) {
A> "Field1: $($b.field1)"
A> "Field2: $($b.field2)"
A> "--------------------"
A> }
A> I desire:
A>
A> Field1: a
A> Field2: b
A> Field1: c
A> Field2: d
A> Field1: e
A> Field2: f
A> But I get:
A>
A> Field1:
A> Field2:
A> --------------------
A> What am I doing wrong?
A>
A> Thanks.
A>
A> altraf
A>