Created
January 10, 2012 14:16
-
-
Save zommarin/1589286 to your computer and use it in GitHub Desktop.
Run a exe from powershell....
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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