Skip to content

Instantly share code, notes, and snippets.

@adamjasinski
Created December 18, 2014 16:17
Show Gist options
  • Save adamjasinski/9fd51fea69d9803a8561 to your computer and use it in GitHub Desktop.
Save adamjasinski/9fd51fea69d9803a8561 to your computer and use it in GitHub Desktop.
$ErrorActionPreference = "Stop"
function exec( [ScriptBlock] $cmd){
( & $cmd ) 2>&1 # TeamCity doesn't show the output without the 2>&1
if($LASTEXITCODE -ne 0){
throw "Exec returned $LASTEXITCODE"
}
}
#Usage example:
#exec { git fetch }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment