title: How to Replace using powershell
body: <p>Here is my vb code.
  This is exactly what i want to do with powershell.</p>
  
  <pre><code>Public Sub Main()
  Dim file As New System.IO.StreamReader(Dts.Variables("User::str_SourcePath").Value.ToString())
  Dim data As String
      data = file.ReadToEnd()
      data = data.Replace("""" &amp; vbCrLf, """" &amp; vbLf)
      data = data.Replace(vbCrLf, " ")
      data = data.Replace(vbCr, vbLf)
      data = data.Replace(Chr(32) &amp; vbCrLf, vbLf)
      data = data.Replace(Chr(32) &amp; vbLf, vbLf)
      data = data.Replace("'", "")
      data = data.Replace(Chr(0), "")
  file.Close()
      Dim writer As New System.IO.StreamWriter(Dts.Variables("User::str_SourcePath").Value.ToString(), False)
  writer.Write(data)
      writer.Flush()
      writer.Close()
  
      Dts.TaskResult = ScriptResults.Success
  End Sub
  </code></pre>
  
  <p>My Powershell Script:</p>
  
  <pre><code>Get-ChildItem "C:\Users\abc\Desktop\Files" | ForEach-Object {
  $Content = Get-Content $_.fullname
  $Content = ForEach-Object { $Content -replace "\r\n","\n" }
  $Content = ForEach-Object { $Content -replace "'","" }
  $Content = ForEach-Object { $Content -replace "chr(0)","" }
  Set-Content $_.fullname $Content -Force
  }
  </code></pre>
  
  <p>I am trying to replace a few ascii characters control code (0 to 10) and from (12 to 15) and (17)  and also from (21 to 30).</p>