Just a quick share as I needed this for something, this function will replace values in a CSV file. It takes the desired column(s) and value(s) to search for and a new value and desired target column as required parameters.
function update-csvColumn{ Param( [Parameter(Mandatory=$true)]$csvContents, #input original CSV file contents here (use import-csv first) [Parameter(Mandatory=$true)][Array]$searchForColumns, #names of the columns you want to base your search on [Parameter(Mandatory=$true)][Array]$searchForValues, #replace rows in $searchForColumn that match these values (in same order!) [Parameter(Mandatory=$true)]$replaceColumn, #set this column to what you specified in $newValue [Parameter(Mandatory=$true)]$newValue #the new value you wish to set $searchForColumn or $replaceColumn to ) if($searchForColumns.Count -ne $searchForValues.Count) {Throw "You must supply an equal number of columns and values to match on"} for($i = 0; $i -lt $csvContents.Count; $i++){ $replace = $True for($c = 0; $c -lt $searchForColumns.Count; $c++){ if($csvContents[$i].$($searchForColumns[$c]) -ne $searchForValues[$c]){ $replace = $False } } if($replace){ $csvContents[$i].$replaceColumn = $newValue } } return $csvContents }