I am trying to run the following command in my Windows 10 PC , and PowerShell version 7.1.2

> Install-Module PowerShellGet, PackageMAnagement -Force -WarningAction SilentlyContinue

But I am getting the below error as shown in the screenshot :

-- No match was found for the specified search criteria and module name 'PackageManagement'.

Note : I am trying to run this command on my Office laptop and it is giving me this error. The same thing if I run on my personal PC , this is working fine.

I am really stuck on this for past 4 days. Please help

enter image description here

Edit :

If I request modules separately , that works .

Meaning , the below works fine ..

Install-Module PowerShellGet -Force -WarningAction SilentlyContinue Install-Module PackageManagement -Force -WarningAction SilentlyContinue

enter image description here

1

There are 1 best solutions below

6
On

If you have an authenticating proxy you'll need to account for that - Powershell does not look at the system proxy settings by default.

Try adding this before you request the module:

    [System.Net.WebRequest]::DefaultWebProxy = [System.Net.WebRequest]::GetSystemWebProxy()
    [System.Net.WebRequest]::DefaultWebProxy.Credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials

If, as the error message suggests, you type Get-PSRepository then it should return PSGallery without error if you have a connection