I am a beginner at PowerShell and scripting/programming but I am trying to write a PowerShell script that will search through each XML document in a directory for a value found in column 1 of a CSV file and replace that found value with the value in column 2 of the same CSV. The script will then need to go to the next row of the CSV and repeat the process and continue until all values in Column 1 of the CSV have been searched for and replaced accordingly.
I've cobbled the following together but I'm at a loss as to how to proceed.
$c = import-csv C:\somecsv.csv)
$xmls2search=get-childitem C:\somedirectory\*.xml
foreach ($xmldoc in $xmls2search)
{
(Get-Content $xmldoc.PSPath) |
Foreach-Object {$_ -replace $c[i].column1name, $c[i].column2name} |
Set-Content $xmldoc.PSPath
}