Skip to content

Install-psresource does not install PSGalleryScripts #709

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

Closed
3 tasks done
demdante opened this issue Jul 14, 2022 · 3 comments · Fixed by #750
Closed
3 tasks done

Install-psresource does not install PSGalleryScripts #709

demdante opened this issue Jul 14, 2022 · 3 comments · Fixed by #750
Assignees
Labels
Milestone

Comments

@demdante
Copy link

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

This issue only affects scripts that are published to the powershell gallery, or psgalleryscripts. For the purposes of this issue, the example script I will use is "Export-PSObjectToINI," You can use "Find-Psresource" to find the "Export-PSObjectToINI" script hosted in the powershell gallery easily:
2022-07-14 15_26_48-Administrator_ Windows PowerShell ISE
But when trying to install the script using "install-psresource", the module doesn't return any error or output, which would typically indicate the resource was successfully installed, but attempting to run the script reveals that it was not installed at all:

2022-07-14 15_29_36-Administrator_ Windows PowerShell ISE

This is a problem that needs to be resolved, as the only way to install scripts from the powershell gallery as of now is to import the old version of powershellget and use the "install-script" command.

Expected behavior

The script should have successfully installed on the local machine.

Actual behavior

The script was not installed on the local machine

Error details

No error to be had.

Environment data

get-module powershellget; $PSVersionTable

ModuleType Version    Name                                ExportedCommands                                                                                               
---------- -------    ----                                ----------------                                                                                               
Binary     3.0.14     PowerShellGet                       {Find-PSResource, Get-PSResource, Get-PSResourceRepository, Install-PSResource...}                             

Key   : PSVersion
Value : 5.1.22000.653
Name  : PSVersion


Key   : PSEdition
Value : Desktop
Name  : PSEdition


Key   : PSCompatibleVersions
Value : {1.0, 2.0, 3.0, 4.0...}
Name  : PSCompatibleVersions


Key   : BuildVersion
Value : 10.0.22000.653
Name  : BuildVersion


Key   : CLRVersion
Value : 4.0.30319.42000
Name  : CLRVersion


Key   : WSManStackVersion
Value : 3.0
Name  : WSManStackVersion


Key   : PSRemotingProtocolVersion
Value : 2.3
Name  : PSRemotingProtocolVersion


Key   : SerializationVersion
Value : 1.1.0.1
Name  : SerializationVersion

Visuals

No response

@ThomasNieto
Copy link
Contributor

This is because Install-PSResource isn't adding the install script path to the Path environment variable so it can be ran without prepending the path. In PowerShellGet v2 Install-Script did this by default and now it seems that feature hasn't been added back yet.

You can get around this for now by using.

$env:Path += ";$env:USERPROFILE\Documents\PowerShell\Scripts"

@demdante
Copy link
Author

This is because Install-PSResource isn't adding the install script path to the Path environment variable so it can be ran without prepending the path. In PowerShellGet v2 Install-Script did this by default and now it seems that feature hasn't been added back yet.

You can get around this for now by using.

$env:Path += ";$env:USERPROFILE\Documents\PowerShell\Scripts"

Ahh. I see. You are right. The script is downloaded to the machine in the location you state. Maybe I will take a crack at modifying the "Install-psresource" function so that it adds the script directory to the PATH environment variable if it is not already present to fix that issue. Thanks for your help, but please keep this issue open until the issue has been addressed. Appreciate it.

@anamnavi
Copy link
Member

Upon further discussion with the team, we feel it is best for consistency across Windows and Linux to not attempt to modify the user's/machine's environment PATH variable, rather emit a warning indicating how the user could do so and specifying the path with which to do so. The script is still installed successfully, but the user would have to modify the environment PATH variable for discoverability. cc @SydneyhSmith

@ghost ghost added the Status: Fixed label Aug 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
4 participants