Skip to content

Install-Module does not work with PSGallery #556

@soroshsabz

Description

@soroshsabz

ITNOA

Hi

I have PowerShell 7.5.4, when I run below command

Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2

as I know https://www.powershellgallery.com/api/v2 is deprecated, and if I try to install some package on PSGallery I got below error

WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.

So I have to use v3 (based on Microsoft Community answer, so I use below command

Unregister-PSRepository -Name 'PSGallery'
Register-PSRepository -Default -SourceLocation 'https://www.powershellgallery.com/api/v3' -InstallationPolicy Trusted

But I got below error

Register-PSRepository: Use 'Register-PSRepository -Default' to register the PSGallery repository.

But as I know, Register-PSRepository -Default does not register correct source location

So I do not know how to resolve this problem?


One strange thing is for example if I try to install Terminal-Icons with Install-Module I got below error

Install-Module -Name Terminal-Icons -Repository PSGallery                                                                                                                                                                
WARNING: Unable to resolve package source 'https://www.powershellgallery.com/api/v2'.
Install-Package: No match was found for the specified search criteria and module name 'Terminal-Icons'. Try Get-PSRepository to see all available registered module repositories.

but I try to install above module with Install-PSResource everything work correctly as below

Install-PSResource -Name Terminal-Icons -Repository PSGallery

I ask similar question on https://stackoverflow.com/q/79879316/1539100

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions