I'm making a simple powershell script to replace SubWCRev in our environment. So I have a lot of template files containing variables like $WCREV$ and so forth.
I'm can't do a simple find and replace on those variables though.. I'm unable to escape the $-character properly.
The find-and-replace is simple;
function FindAndReplace {
param(
[string]$inputFile,
[string]$outputFile,
[string]$findString,
[string]$replaceString)
(Get-Content $inputFile) | foreach {$_ -replace $findString, $replaceString} |
Set-Content $outputFile
}
And I've tried many alternatives for the $findString..
Tried;
$findString = '$WCREV$'
$findString = '`$WCREV`$'
$findString = "`$WCREV`$"
$findString = "$WCREV$"
Can't make any of it work. If I try just WCREV it replaces it alright, but then I'm left with the $ of course.. I guess I could modify my templates but it seems like a silly little problem so it's probably doable, right?