Skip to content

irm | iex leaves install.ps1's settings in the user's session: the preference, strict mode, and the script's functions and variables #982

Closed

Description

@David-Noble-at-work

irm … | iex runs install.ps1 in the user's own scope, so what the script sets stays in the session after it ends:

The script-block form, & ([scriptblock]::Create((irm …))), runs in a scope of its own and leaves none of it; it's the preferred one-liner (ruled 2026-09-27 on #946). Measured under pwsh 7.4.6, 2026-09-29, drafting #965: after a failed iex run, Main and $Version remain in the session. Until #965, a failure closed the window, so this showed only after a success; with #965 it shows after a failure too.

Found drafting #965 (PR B of #949). The documents added by #946 note it beside the iex form.

Resolution

A design change to install.ps1, for the owner to rule on. One option: the whole script becomes a script block invoked in its own scope, & { … } @PSBoundParameters, so iex leaves nothing behind either. Another: keep iex as documented, with its note, and leave it.

Plan and design documents

Kind Document
Plan docs/plans/fix/982-irm-iex-leaves-install-ps1-s.md

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