Proxy Issues with Install Module

17,882

Solution 1

A per Keith Hill's suggestion, adding the PowerShellGallery repo manually worked:

Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2

I had trouble getting this working with the -proxy switch, so I set the proxy via netsh which did the trick:

netsh winhttp set proxy proxy-server="http=myproxy:8080"

Solution 2

Proxy can be set via -Proxy parameter of many network cmdlets or $PSDefaultParameterValues = @{ "*:Proxy"="http://proxy:port" }

Share:
17,882

Related videos on Youtube

J1raya
Author by

J1raya

Infrastructure person who's been playing with Windows batch, vbscript & powershell (n liners) for a number of years. Getting more serious with Powershell and automating everything I can until I'm out of a job. I've also started learning python. All part of an attempt to reinvent myself professionally.

Updated on June 04, 2022

Comments

  • J1raya
    J1raya almost 2 years

    Running the following setup:

    • Server 2012 R2
    • PSVersion: 4.0
    • WSManStackVersion: 3.0
    • Git version 2.11.1
    • Package Management Preview - x64: 10.0.10586.117
    • SharpZipLib: 0.86.0
    • NuGet: 2.8.5.208

    Trying to install the posh-git module gives:

    PowerShellGet\Install-Module posh-git -Scope CurrentUser
    

    But getting

    PackageManagement\Install-Package : No match was found for the specified search criteria and module name 'posh-git'.

    When trying Get-PackageSource and Get-PSRepository I get

    WARNING: Unable to find package sources

    and

    WARNING: Unable to find module repositories.

    I'm sitting behind a TMG proxy and tried using the -Proxy switch and setting setting winttp proxy with no luck.

    • Keith Hill
      Keith Hill over 7 years
      Try adding the PowerShellGallery repo manually Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -Proxy ... -ProxyCredential (Get-Credential). If that works, make sure Get-PSRepository returns the newly registered repo.
    • J1raya
      J1raya over 7 years
      Thanks Keith, that did the trick in the end. I've since made an exception in my proxy for the machine and noticed that PowerShell 5.1 seems to be a bit easier to configure in that respect.
    • Nick.McDermaid
      Nick.McDermaid about 5 years
      If you are having issue with Register-PSRepository returning errors, first run Get-PSRepository. You might find the it is registered is untrusted, in which case you should use Set-PsRepository