Outer.ps1:
& "$env:WINDIR\syswow64\WindowsPowerShell\v1.0\powershell.exe" -NonInteractive -NoProfile -ExecutionPolicy Bypass -Command "& '.\Inner.ps1'; Write-Host "BLOCK: $LastExitCode"; exit $LastExitCode"
Write-Host "OUTSIDE: $LastExitCode"
Inner.ps1:
exit 3
Executing Outer.ps1
outputs:
BLOCK: 1
OUTSIDE: 1
What, why? Inner.ps1 clearly exited with exit code 3. What's the problem?
Note: If I change Inner.ps1
to return 0
, I receive the following output:
BLOCK: 0
OUTSIDE: 0
Somehow, all other codes than 0 are defaulted to 1, why?