Find & Replace Content in Files

# Change the -Path, -Pattern and -replace inputs
Get-ChildItem -Path “F:\Power Shell Script\Temp” *.config -recurse |
Select-String -Pattern “OLD VALUE” |
Select-Object Path | Get-ChildItem -recurse|
Foreach-Object {
$c = ($_ | Get-Content)
$c = $c -replace ‘OLD VALUE’,’NEW VALUE’
Write-Host $_.FullName
[IO.File]::WriteAllText($_.FullName, ($c -join “`r`n”))
}

Explanation

1. Find & Replace