Proxy Issues with Install Module
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" }
Related videos on Youtube
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, 2022Comments
-
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
andGet-PSRepository
I getWARNING: 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 over 7 yearsTry adding the PowerShellGallery repo manually
Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2/ -Proxy ... -ProxyCredential (Get-Credential)
. If that works, make sureGet-PSRepository
returns the newly registered repo. -
J1raya over 7 yearsThanks 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 about 5 yearsIf you are having issue with
Register-PSRepository
returning errors, first runGet-PSRepository
. You might find the it is registered is untrusted, in which case you should useSet-PsRepository