title: How do I avoid getting data printed to stdout in my return value?
body: <p>In doing some Powershell automation, I'm having trouble with the way that data written to stdout by a <code>.cmd</code> file is automatically captured. I have two functions that do something like the following:</p>
  
  <pre><code>function a {
      &amp; external.cmd # prints "foo"
      return "bar"
  }
  
  function b {
      $val = a
      echo $val # prints "foobar", rather than just "bar"
  }
  </code></pre>
  
  <p>Basically, data that <code>external.cmd</code> sends to stdout is added to the return value of <code>a</code>, even though all I really want to return from <code>a</code> is the string that I specified. How can I prevent this?</p>