Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PowerShell installer doesn't work on Posh 5.1 #17

Open
Szeraax opened this issue Aug 12, 2021 · 1 comment
Open

PowerShell installer doesn't work on Posh 5.1 #17

Szeraax opened this issue Aug 12, 2021 · 1 comment

Comments

@Szeraax
Copy link

Szeraax commented Aug 12, 2021

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.

@Szeraax
Copy link
Author

Szeraax commented Aug 12, 2021

As a workaround for installing on PowerShell 5 and below, I made a little function before running the iex:

function New-TemporaryFile {New-Item -ItemType File -Path $ENV:TEMP\$([System.IO.Path]::GetRandomFileName()) }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant