警告:无法找到模块存储库

yuh*_*dai 7 docker windows-server-2016

我试图在激活的Windows Server 2016标准上安装Docker.我执行“Install-Module -Name DockerMsftProvider -Repository PSGallery -Force”但失败了.它建议找不到PSGallery.我执行了"Get-PSRepository".错误:

警告:无法找到模块存储库.

我用谷歌搜索了3种方法来解决它,但没有奏效.

  1. Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Verbose -Force成功执行了.

  2. 我成功安装了巧克力.

  3. 我执行"powershell Register-PSRepository -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但失败了.它让我使用"Register-PSRepository -Default".

我试过"powershell Register-PSRepository -Default -Name "PSGallery" –SourceLocation "https://www.powershellgallery.com/api/v2/" -InstallationPolicy Trusted"但仍然失败了.我怎么能解决这个问题?

Ale*_*dre 47

2020 年 4 月起PowerShell Gallery 的 TLS 1.0 和 1.1 已弃用,cmdlet Update-Module 和 Install-Module 已损坏。因此,根据这篇文章,需要执行一些命令才能使它们再次生效:

[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 
Install-Module PowerShellGet -RequiredVersion 2.2.4 -SkipPublisherCheck
Run Code Online (Sandbox Code Playgroud)

如果这仍然不起作用,请运行以下命令:

[Net.ServicePointManager]::SecurityProtocol = [Net.ServicePointManager]::SecurityProtocol -bor [Net.SecurityProtocolType]::Tls12
Register-PSRepository -Default -Verbose
Set-PSRepository -Name "PSGallery" -InstallationPolicy Trusted
Run Code Online (Sandbox Code Playgroud)

NuGet.org 最近也弃用了 TLS 1.0 和 1.1: nuget.org 已弃用 TLS 1.0 和 1.1 但这也是之前宣布的

  • 未找到名为“PSGallery”的存储库 (4认同)

小智 22

简单地运行Register-PSRepository -Default(没有任何附加参数)对我有用。之后,画廊注册成功:

PS C:\Windows\system32> Get-PSRepository

Name                      InstallationPolicy   SourceLocation
----                      ------------------   --------------
PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2/
Run Code Online (Sandbox Code Playgroud)


And*_*dre 13

我的问题是缺少代理配置

来自评论的最佳解决方案:https : //www.zerrouki.com/working-behind-a-proxy/
感谢@Vadzim


在 PowerShell 中打开配置文件

PS> notepad $PROFILE
Run Code Online (Sandbox Code Playgroud)

这将使用您的配置文件设置打开记事本,将创建或不存在。
然后加:

[system.net.webrequest]::defaultwebproxy = new-object system.net.webproxy('http://webproxy.yourCompany.com:PORT')
[system.net.webrequest]::defaultwebproxy.credentials = [System.Net.CredentialCache]::DefaultNetworkCredentials
[system.net.webrequest]::defaultwebproxy.BypassProxyOnLocal = $true
Run Code Online (Sandbox Code Playgroud)

不知何故,我的本地代理已设置但不起作用。Docker 也有同样的问题,=>

> PS> [Environment]::SetEnvironmentVariable("HTTP_PROXY", http://username:password@proxy:port/", [EnvironmentVariableTarget]::Machine)
Run Code Online (Sandbox Code Playgroud)

然后重启docker服务


小智 6

我收到了类似的消息。我跑了Register-PSRepository -default,注册没问题。然后我跑了Set-PSRepository -Name PSGallery -InstallationPolicy Trusted。我没有组合这些命令,但它起作用了。

我花了一个多小时试图以与 Exchange Online 相同的方式将凭据传递给代理,但我不喜欢。我断开连接并改为使用我们的访客 WiFi。