How can I replace every occurrence of a String in a file with PowerShell? - Stack Overflow

PHOTO EMBED

Mon Nov 04 2024 01:07:23 GMT+0000 (Coordinated Universal Time)

Saved by @baamn

$path=$args[0]
$oldString=$args[1]
$newString=$args[2]

Get-ChildItem -Path $path -Recurse -File | 
ForEach-Object { 
    (Get-Content $_.FullName).replace($oldString,$newString) | Set-Content $_.FullName 
}
content_copyCOPY

https://stackoverflow.com/questions/17144355/how-can-i-replace-every-occurrence-of-a-string-in-a-file-with-powershell