title: catching return code of a command with "invoke-command" - Powershell 2
body: <p>I am using "invoke-command" to execute a script on a remote machine.</p>
  
  <pre><code>invoke-command -computername &lt;server_name&gt; -scriptblock {command to execute the script}
  </code></pre>
  
  <p>My script returns "-1" when there are any errors.
  So, I wanted to ensure that script has executed successfully by checking the return code.</p>
  
  <p>I tried as follows.</p>
  
  <pre><code>$code = invoke-command -computername ....
  </code></pre>
  
  <p>But it returns nothing.</p>
  
  <p>Doesn't <code>Invoke-command</code> catch return code of script block?</p>
  
  <p>Is there other way to resolve this?</p>