title: How to redirect the output of a PowerShell to a file during its execution
body: <p>I have a PowerShell script for which I would like to redirect the output to a file. The problem is that I cannot change the way this script is called. So I cannot do:</p>
  
  <pre><code> .\MyScript.ps1 &gt; output.txt
  </code></pre>
  
  <p>How do I redirect the output of a PowerShell script during its execution?</p>