title: How to have powershell script execute batch command in same terminal
body: <p>I have a powershell 2 script that I'm trying to develop. The purpose of this script is to wrap around a batch script and intelligently choose what version of said batch script to run. Somewhere along the lines in my code I have some logic that goes like this:</p>
  
  <pre><code>&amp; $myCommand $args
  </code></pre>
  
  <p>$myCommand is the fully qualified filename of the batch file I want to run. $args is the args passed into this script. This works except it opens up a command window when running $myCommand. How do I prevent this so that the output is within the same powershell shell?</p>
  
  <p>What's odd is that if I execute the command directly, it shows up the way I want it. So something like:</p>
  
  <pre><code>C:\myCommand.bat $args
  </code></pre>
  
  <p>Given that I need to choose which command I want to run at runtime, how do I make it so the output is in the same shell when I use the '&amp;' to execute the command in the variable? Thanks!</p>