title: Basic PowerShell Script Issue: "Expressions are only allowed as the first element of a pipeline"
body: <p>I'm trying to write a simple script that reads a file, locates a string, replaces the string with another string, and stores all new file contents (with replaced string), in a new file. Here is what I'm using:</p>
  
  <pre><code>(Get-Content C:\file1.txt) | {$_ -replace "this:text", "withthis:text"} | Set-Content C:\file2.txt
  </code></pre>
  
  <p>The error I'm receiving is: "Expressions are only allowed as the first element of a pipeline"</p>
  
  <p>I'm pretty sure this is because of the colon ":" character being in both the string I'm locating and replacing it with. I've tried escaping the colon character with "\" and "`" characters, but I'm receiving the same errors. Does anyone know what's wrong with this?</p>
  
  <p>Thanks for the help.</p>