title: How to tee the output streams of the current PowerShell script?
body: <p>I have a PowerShell script that outputs to stdout and stderr. I'd like to tee those to a couple log files at the same time.</p>
  
  <p>What's the best way to do this?</p>
  
  <p>A couple things I've considered:</p>
  
  <ul>
  <li><em>Wrap write-error and write-output with a function that does the tee.</em>
  <ul>
  <li>I don't like this much because (a) I lose my easy ability to just put a value on a line and have it automatically output and (b) I'd have to wrap every place that I'm calling something, including native exe's, that may have output and wrap those as well.</li>
  </ul></li>
  <li><em>Wrap in an outer script that does the tee.</em>
  <ul>
  <li>This is a little better but now I have the issue of needing to duplicate the <code>param()</code> block from the inner script in the outer script. I could move the param() block entirely but I also want to call the inner script sometimes for testing purposes (i.e. not get the tee). I suppose I could make that an optional behavior in the outer script..</li>
  </ul></li>
  </ul>
  
  <p>I remember back when I used to write some perl there was a convenient way to redirect all stdout/err output globally, via a hook. Is something like this possible with PowerShell?</p>