Prerequisites
Steps to reproduce
I noticed that the Start-Process cmdlet sometimes does not populate the ExitCode property in the output, I believe it should.
This happed at least when -PassThru, -Wait, and -NoNewWindow switches are provided. -NoNewWindow seems to be the reason, since the exit code is available without it.
Steps to reproduce
You can see this behavior with this simple test script
Set-Content -Value "exit 1" -Path script.ps1
$p = start-process "pwsh" script.ps1 -PassThru -NoNewWindow -Wait
$p.ExitCode # Should output: 1
$p = start-process "pwsh" script.ps1 -PassThru -Wait
$p.ExitCode # Outputs: 1
Expected behavior
PS C:\> set-content -Value "exit 1" -Path script.ps1
PS C:\> $p = start-process "pwsh" script.ps1 -PassThru -NoNewWindow -Wait
PS C:\> $p.ExitCode
1
PS C:\> $p = start-process "pwsh" script.ps1 -PassThru -Wait
PS C:\> $p.ExitCode
1
Actual behavior
PS C:\> set-content -Value "exit 1" -Path script.ps1
PS C:\> $p = start-process "pwsh" script.ps1 -PassThru -NoNewWindow -Wait
PS C:\> $p.ExitCode
PS C:\> $p = start-process "pwsh" script.ps1 -PassThru -Wait
PS C:\> $p.ExitCode
1
Error details
No response
Environment data
PS C:\> $PSVersionTable
Name Value
---- -----
PSVersion 7.4.0-preview.5
PSEdition Core
GitCommitId 7.4.0-preview.5
OS Microsoft Windows 10.0.20348
Platform Win32NT
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
Visuals
No response
Prerequisites
Steps to reproduce
I noticed that the
Start-Processcmdlet sometimes does not populate theExitCodeproperty in the output, I believe it should.This happed at least when
-PassThru,-Wait, and-NoNewWindowswitches are provided.-NoNewWindowseems to be the reason, since the exit code is available without it.Steps to reproduce
You can see this behavior with this simple test script
Expected behavior
Actual behavior
Error details
No response
Environment data
Visuals
No response