PowerShell – Insert string in text file on the next line after another string

Question:

This seems like a simple one, but I just can’t wrap my head around it / find a post covering it

I’m trying to use PowerShell to modify a text (config) file
Find where a specific string (A) occurs, then add another string (B) to the next line after. Preserving the line where string (A) occurs

So the problem is I can’t do a simple find and replace as the line where string (A) occurs has other text after it

Here’s for hoping someone smarter than I knows the trick. Cheers

Answer:

Source:

PowerShell – Insert string in text file on the next line after another string by licensed under CC BY-SA | With most appropriate answer!

Leave a Reply