0
$content = Get-Content("d:\gfile.txt")
$content = $content.Replace("sometext", "replacedtext")
$content | Out-File "d:\newfile.txt"

This works for me - really good - I can convert SQL files to this. Using Read-Host I can store the new database info in a variable for the global varible settings in the script.

What I need to work out is - how can I do this for multiple strings in the same variable without running this for each replacement string?

3
  • Not sure I understand your question... can you clarify? Probably worth including some sample input and desired output. Ta! Commented Mar 20, 2017 at 11:57
  • The thing is, i see multiple posts for use of -Replace - How do you input or replace entire large chunks of elements in XML though, i.e. starting with < Massive section /> Commented Mar 27, 2017 at 13:08
  • That still doesn't clarify things. Perhaps a proper example with inputs and desired outputs would help illustrate your problem. Commented Mar 27, 2017 at 15:58

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.