title: How to capture error messages thrown by a command?
body: <p>I am writing a PowerShell script where in I need to capture the error message that it's throwing. Note: according to PowerShell, there is no error and command is executed successfully.</p>
  
  <p>For example: I tried to download a package from SVN Link. The Link actually is not present. The script is showing me error message on the console. However, when I tried to check <code>$_</code> or <code>$?</code> or <code>$error</code>, I did not see any error message. However, <code>$LASTEXITCODE</code> returned value 1. I need to get the exact error message.</p>