Hello, I am trying to handle an error in Execute-Process with my own try/catch blocks separate from the blocks try/catch blocks in the main script. This if for cleaning up mounted wim files if the installer fails. This is some example code below. The process I am running fails with exit code 127 but Execute-Process does not “trip” the try/catch logic when it fails and the catch block is completely skipped. Does anyone know what I may be missing or if this is working as intended?
$returncode = Execute-Process -path “my.exe” -parameters “–silent” -ExitOnProcessFailure $False -PassThru
$mainexitcode = $returncode.ExitCode
Show-DialogBox -text “$mainexitcode. I failed!”