Replace multiline text in a file using Powershell without using Regex

Question:

I have the following Powershell script:

This doesn’t seem to be replacing the text. Is it an issue with the multiline strings, or the limits of the Replace() method? I would prefer to do the replace without bringing in regex.

Answer:

What version of PowerShell are you using? If you’re using v3 or higher, try this:

Source:

Replace multiline text in a file using Powershell without using Regex by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply