You can use PowerShell Get-Content and Set-Content cmdlets to replace every occurrence of a string in a file. Here is a quick example for you –
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
## Write something into a file echo @' Welcome to the world of PowerShell PowerShell is very powerfull '@ > myscript.txt ## Get the content Get-Content -Path .\myscript.txt ## Replace "PowerShell" with "Linux" (Get-Content .\myscript.txt) -replace 'PowerShell', 'Linux' | Set-Content .\myscript.txt ## Validate Get-Content -Path .\myscript.txt |