PowerShell function to replace a string in a given text file

function Replace-StringInFile {


    [System.IO.File]::WriteAllText($file, [System.IO.File]::ReadAllText($file).Replace($searchString, $replaceString))

Function usage:

Replace-StringInFile -file "C:\input.csv" -searchString "http" -replaceString "https"

About Author

Christian Unnerstall

Christian Unnerstall, founder of devshooin.com, enjoys designing and building things that look nice and work well, whether it's websites or services within the interwebs. Have questions - feel free to reach out to him. Enjoy

Leave a Reply