title: Powershell script is failing when I am trying to replace parameters using ForEach-Object
body: <p>Function in my PowerShell script is as follows:</p>
  
  <pre><code>function replace-file-content([string] $path, [string] $replace, [string] $replacewith) {
      (Get-Content $path) |
        Foreach-Object -replace{$replace,$replacewith}|
          Out-File $path
  
  }
  </code></pre>
  
  <p>Error I am getting is:</p>
  
  <blockquote>
    <p>ForEach-Object : Cannot bind parameter 'Process'. Cannot convert the "-replace" value of type "System.String" to type "System.Management.Automation.ScriptBlock".</p>
  </blockquote>