How can I run an executable in PowerShell and through an if statement determine whether it succeeded or failed?
More specifically I\'m trying to get devenv.exe to bu
Have you tried using the $LASTEXITCODE
variable? It will contain the exit code of the last .exe that was invoked.
.\YOUREXE.exe
if($LASTEXITCODE -eq 0)
{
Write-Host "The last PS command executed successfully"
}
else
{
Write-Host "The last PS command failed"
}