I have some functions that can be used to find an array index and then update a specific value in that array. However, let’s say you don’t want to use a function and instead only want to update a value once.
This command can be used to search for a multi-dimensional array row by a column value and then update another column in that row.
1 2 3 4 5 6 7 8 |
# Search for array row by one column & update another column. $newValue = "Here's a new value" $searchValue = "search_value" $newValue = ($ArrayName.Rows | Where-Object {$_.ArrayColumn1 -eq $searchValue}).ArrayColumn2 |
To simply return a single row of an array, simple run this, being sure to modify the search value:
$ArrayName.Rows | Where-Object {$_.column -eq "Search_Value"}