Skip to content

PowerShell installer doesn't work on Posh 5.1 #17

@Szeraax

Description

@Szeraax

The PowerShell installer uses the cmdlet New-TemporaryFile, which was introduced in PowerShell Core (v6). Because of that, the $temp var doesn't get populated and the download does not happen.

You need to do at least one of the following to fix:

  1. Put a note in the documentation that says to use Pwsh (PowerShell core 6+)
  2. Put a #Requires -Version 6 in the get.ps1 file
  3. Put in custom $PSVersionTable validation and error message that lets people know why it won't run on PowerShell 5 and below
  4. Remove cmdlets such as New-TemporaryFile that are only available in PowerShell core

Personally, I'd suggest telling people to only use it on Pwsh 7+ since 6 is already deprecated. I'd suggest doing #1 and #2 (but for 7 instead of 6). Option 4 is also nice if you actually intend for this to be installable without Pwsh on the machine. New-temporaryFile is likely the only thing that would need changed. Option 3 would only be the case if you're worried that this error message is too generic and hard to under stand: The script '...' cannot be run because it contained a "#requires" statement for PowerShell 7.0. The version of PowerShell that is required by the script does not match the currently running version of PowerShell 5.1.

If you tell me what direction you'd like to go, I'll happily submit a PR.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions