Invoke an exe from PowerShell and get feedback on success or failure
.\YOUREXE.exe
if($LASTEXITCODE -eq 0)
{
Write-Host "The last PS command executed successfully"
}
else
{
Write-Host "The last PS command failed"
}
Have you tried using the $LASTEXITCODE
variable? It will contain the exit code of the last .exe that was invoked.
- https://devblogs.microsoft.com/powershell/errorlevel-equivalent/