Skip to content

install.ps1's exit closes the user's PowerShell window: under irm | iex and the script-block form, exit ends the session, not the script #965

Closed

Description

@David-Noble-at-work

install.ps1 ends with exit in two places: -Help (line 47) and every failure, through Write-Fatal (line 75). A script run as a file exits only itself. A script run through irm … | iex, or through the script-block form & ([scriptblock]::Create((irm …))), is not a file, so its exit ends the PowerShell session that typed it. That is both of the published one-liners, and the script-block form is the preferred one (ruled 2026-09-27 on #946). Every install that fails, and every -Help, closes the user's window and takes the error message with it.

Shown under pwsh 7.x on DANOBLE-UD24-1, 2026-09-27:

$ pwsh -NoProfile -Command '& ([scriptblock]::Create("Write-Host inside; exit 3")); Write-Host "after: the session survived"'
inside
$ echo $?
3

iex does the same. Windows PowerShell 5.1 behaves the same way; that is expected, not yet shown.

Resolution

The script never calls exit. -Help returns. A failure throws a terminating error carrying the message, which ends the script and leaves the session and the message on screen. Run as a file (pwsh -File install.ps1), an uncaught terminating error still exits 1, so callers that read the exit code see no change.

Plan and design documents

Kind Document
Plan docs/plans/feature/950-installers-take-base-team-and.md
Design #798

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions