Quantcast
Channel: Windows PowerShell forum
Viewing all articles
Browse latest Browse all 21975

Read file and then replace word from csv file

$
0
0

I want to replace words in config files, an replace the valor with value that are in csv file for example:

User      New User

abc        qwr

wer       123456

I want to search the word  "abc" and replace it for "qwr"

I write this but i do not know how to add

$configFiles=get-childitem . *.config -rec
foreach ($file in $configFiles)
{
$file.PSPath >> log.log
$a= "" + $file.PSPath + ".bkp"
cp $file.PSPath $a
(Get-Content $file.PSPath) |
Foreach-Object {$_ -replace "Decchi", "mono"} |
Set-Content $file.PSPath

}


adecchi


Viewing all articles
Browse latest Browse all 21975

Trending Articles