title: How to capture output in a variable rather than a logfile?
body: <p>This would write the output to a logfile:</p>
  
  <pre><code>&amp; $Env:WinDir\system32\inetsrv\appcmd.exe &gt;test.log
  </code></pre>
  
  <p>But what if I wanted to keep the output in a string variable to use it in the email body?</p>
  
  <p>I tried this without any luck..</p>
  
  <pre><code>$test = ""
  &amp; $Env:WinDir\system32\inetsrv\appcmd.exe &gt;$test
  
  Write-Host $test
  </code></pre>