title: Powershell - How to out-host and set a variable with the ouput
body: <p>I have the following powershell snippet:</p>
  
  <pre><code>$output = &amp; "$backup.exe" @("/remoteShare", $remoteShare)  2&gt;&amp;1
  </code></pre>
  
  <p>This sets $output but the problem with is it does not write the output of backup.exe to the command console window. As a solution I tried:</p>
  
  <pre><code>$output = &amp; "$backup.exe" @("/remoteShare", $remoteShare)  2&gt;&amp;1 | out-host
  </code></pre>
  
  <p>This solution outputs to the command console window but the $output is null.</p>
  
  <p>tl;dr How do I run an exe from PS and display the output of that exe to the command console AND save the output in a variable??</p>