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

Module does not work with powershell 5.0 and below #23

Open
kiprasn opened this issue Feb 27, 2019 · 2 comments
Open

Module does not work with powershell 5.0 and below #23

kiprasn opened this issue Feb 27, 2019 · 2 comments

Comments

@kiprasn
Copy link

kiprasn commented Feb 27, 2019

flush_command = "Set-PSRepository #{@resource[:name]}"

(Probably another file, this is initial investigation)

Because of how the source code is written, it always executes a command with first parameter being the name of the resource.

In the working example you provide it says it should work with powershell 5 and 6 (https://github.com/hbuckle/puppet-powershellmodule/blob/master/README.md), however, it only works with powershell 5.1, with 5.0 it doesn't.

The issue is that the command "Set-PSRepository" doesn't take the first string as a parameter in powershell 5.0. Also, there would be an issue if you were to set a 'name' parameter inside puppet, it errors, because there are 2 name parameters.

Command's Set-PSRepository' required parameter 'name as positional parameter '0' is only introduced in 5.1 as seen here:

https://docs.microsoft.com/en-us/powershell/module/powershellget/set-psrepository?view=powershell-5.0

https://docs.microsoft.com/en-us/powershell/module/powershellget/set-psrepository?view=powershell-5.1

Possible solution is not to include resource name in the flush command, so you would always have to explicitly say the name of the PSRepository and it would work with powershell 5.0 and below.

@hbuckle
Copy link
Owner

hbuckle commented Mar 6, 2019

Hi @kiprasn - Thanks for the report. Just to check, if you install the latest version of PowerShellGet from the PSGallery does the problem go away?

@nmaludy
Copy link
Contributor

nmaludy commented Apr 14, 2020

Same problem here. Yes, installing that module does get it working.

Would be nice if there was a guard to see if PowerShellGet was installed before trying to import it, then disable the feature if it doesn't exist.

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

3 participants