I have an array object $ a that returns the output as shown below.

And by making $ a [0] .Name, I can access every record of "Name", $ a [0]. Available I can access the appropriate available space.
I have another array: $ b, which contains some names, for example $ b returns me two names "sandeep_aggr1" and "aggr4". It is just an array (no properties like Name, Avaiable), not an object, so it cannot use Compare-Object.
I want to delete other entries in the original $ a object, with the exception of those whose "Name" is equal to "sandeep_aggr1" and "aggr4".
This is what I do.
foreach($bb in $b) { foreach($aa in $a) { if($aa.Name -ne $bb) { $aa.Remove($aa.Name) } } } echo $a
But, I donβt see that the items are deleted, am I missing something? Any help appreciated
source share