title: -command's exit code is not the same as a script's exit code
body: <p>I need to run a script with PowerShell -Command "&amp; scriptname", and I would really like it if the exit code I got back from PowerShell was the same as the exit code the script itself returned.  Unfortunately, PowerShell returns 0 if the script returns 0, and 1 if the script returns any non-zero value as illustrated below:</p>
  
  <pre><code>PS C:\test&gt; cat foo.ps1
  exit 42
  PS C:\test&gt; ./foo.ps1
  PS C:\test&gt; echo $lastexitcode
  42
  PS C:\test&gt; powershell -Command "exit 42"
  PS C:\test&gt; echo $lastexitcode
  42
  PS C:\test&gt; powershell -Command "&amp; ./foo.ps1"
  PS C:\test&gt; echo $lastexitcode
  1
  PS C:\test&gt;
  </code></pre>
  
  <p>Using [Environment]::Exit(42) almost works:</p>
  
  <pre><code>PS C:\test&gt; cat .\baz.ps1
  [Environment]::Exit(42)
  PS C:\test&gt; powershell -Command "&amp; ./baz.ps1"
  PS C:\test&gt; echo $lastexitcode
  42
  PS C:\test&gt;
  </code></pre>
  
  <p>Except that when the script is run interactively, it exits the whole shell. Any suggestions?</p>