Skip to content

Instantly share code, notes, and snippets.

@zommarin
Created January 10, 2012 14:16
Show Gist options
  • Save zommarin/1589286 to your computer and use it in GitHub Desktop.
Save zommarin/1589286 to your computer and use it in GitHub Desktop.
Run a exe from powershell....
function Run-Exe() {
$Executable = $args[0]
$Arguments = @( $args | Select -Skip 1 )
Write-Host "RUNNING COMMAND: $Executable $Arguments"
$Output = & $Executable @Arguments 2>&1
if ($LASTEXITCODE) {
Write-Error "COMMAND FAILED: $Executable $Arguments`nExit code = $LASTEXITCODE`nOutput = $Output"
throw "COMMAND FAILED: $Executable $Arguments`nExit code = $LASTEXITCODE`nOutput = $Output"
}
Write-Host "COMMAND OUTPUT: $Output"
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment