You need to access the correct element in the array. The array here is $ds
as it contains one object per row. Each row has a B
-property that you can read and set. This will work:
#Modify second row's B-value (44) to 9
$ds[1].B = 9
What might confuse you is that $ds.b[1]
actually returns 44
while using PowerShell 3.0 or later. This is because of a feature called member enumeration, where $ds.B
will return the B
-value for every object in the array and then [1]
selects the second value which is 44
. What's important to know is that member enumeration returns a read-only collection by design, so you can't modify the values that way.