title: Powershell Replace specific string in files and save
body: <p>Hello PowerShell cracks,
  I need some help in a script. I want to replace a specific string in a file, a version info, with a variable.
  From searching google, following script should do it, by using the -replace.</p>
  <pre><code>$filecontent = Get-Content -Path $temp
  $newContent = $filecontent -replace 'V#+#+#', $version
  $newContent | Set-Content -Path $temp
  </code></pre>
  <p>The file is a .kl (KAREL)-file and looks like that:</p>
  <pre><code>---+----------------------------------------------------------------------------------------------+
  -- | Mainfile                                                         |
  ---+----------------------------------------------------------------------------------------------+
  PROGRAM plx
  %COMMENT = 'PLx Com V#+#+#'
  %NOLOCKGROUP
  %NOPAUSESHFT
  %NOPAUSE = ERROR + COMMAND + TPENABLE
  %NOABORT = ERROR + COMMAND
  %stacksize = 8000
  %environment strng
  %environment uif
  %environment sysdef
  %environment memo
  %environment kclop
  %environment bynam
  %environment fdev
  %environment flbt
  %environment regope
  %include klevccdf
  %include klevkeys
  %include klevkmsk
  </code></pre>
  <p>It should replace the &quot;V#+#+#&quot; string in line 5 with a string from a variable. But PowerShell do not find the string in the file content. I don't understand where's the issue.</p>
  <p>Thanks in advance for your help.</p>