I am new to powershell scripting. I have tried to develop a script using powershell major version 5. The objective of my script is to replace few string literals in a template file, with some strings. Note that, one of the string literal is replaced by a content of a file.
$ReleaseScript = Get-Content $SourceFile -Raw
(Get-Content $ChangeSetTemplatefile -Raw) |
ForEach-Object {
$_ -replace '<insert_script_here>', $ReleaseScript `
-replace '<username>' , $UserName
}
| Set-Content $CSDestinationFile"
The above replace works fine except when the file content in $ReleaseScript itself has $_. Is there a way to have a escape character to avoid replacing the replace string content or any other way to achieve the objective ?