Powershell 警告:找不到模块存储库

Powershell 警告:找不到模块存储库,powershell,docker,windows-server-2016,Powershell,Docker,Windows Server 2016,我试图在激活的windows server 2016 standard上安装Docker。 我执行了“安装模块-名称dockermstftprovider-存储库PSGallery-Force”,但失败。建议找不到PSGallery。我执行了“获取PSRepository” 错误: 警告:找不到模块存储库。 我用谷歌搜索了3种方法来解决这个问题,但没有一种有效 我成功地执行了Install PackageProvider-Name NuGet-MinimumVersion 2.8.5.201-V

我试图在激活的windows server 2016 standard上安装Docker。 我执行了
“安装模块-名称dockermstftprovider-存储库PSGallery-Force”
,但失败。建议找不到PSGallery。我执行了
“获取PSRepository”

错误:

警告:找不到模块存储库。

我用谷歌搜索了3种方法来解决这个问题,但没有一种有效

  • 我成功地执行了
    Install PackageProvider-Name NuGet-MinimumVersion 2.8.5.201-Verbose-Force

  • 我成功地安装了巧克力

  • 我执行“powershell注册PSRepository-名称“PSGallery”-SourceLocation”https://www.powershellgallery.com/api/v2/“-InstallationPolicy受信任”但失败。它要求我使用
    “Register PSRepository-Default”

  • 我尝试了
    “powershell注册PSRepository-默认-名称“PSGallery”-SourceLocation”https://www.powershellgallery.com/api/v2/“-InstallationPolicy受信任”
    ,但仍然失败


    如何解决这个问题?

    只需运行
    注册PSRepository-Default
    (没有任何附加参数)就可以了。之后,画廊成功注册:

    PS C:\Windows\system32> Get-PSRepository
    
    Name                      InstallationPolicy   SourceLocation
    ----                      ------------------   --------------
    PSGallery                 Untrusted            https://www.powershellgallery.com/api/v2/
    
    我的问题是缺少代理配置 来自评论的最佳解决方案:
    多亏了


    在PowerShell开放配置文件中

    PS> notepad $PROFILE
    
    这将使用您的个人资料设置打开记事本,将创建不存在的记事本。
    然后添加:

    [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
    
    不知怎的,我的本地代理已设置,但无法工作。 后来Docker也出现了同样的问题,=>

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

    然后重新启动docker服务

    我收到了类似的消息。我运行了
    Register PSRepository-default
    ,它注册了ok。然后我运行了
    Set PSRepository-Name PSGallery-InstallationPolicy Trusted
    。我没有合并命令,但它起作用了

    我花了一个多小时试图将凭据传递给代理,就像我在Exchange Online上所做的那样,但没有爱情。我断开连接并使用了我们的来宾WiFi。

    使用,cmdlet更新模块和安装模块出现故障。因此,需要执行一些命令以使其重新激活:

    [Net.ServicePointManager]::SecurityProtocol=[Net.SecurityProtocolType]::Tls12
    安装模块PowerShellGet-必需版本2.2.4-跳过发布者检查
    
    如果仍然不起作用,请运行以下命令:

    [Net.ServicePointManager]::SecurityProtocol=[Net.ServicePointManager]::SecurityProtocol-bor[Net.SecurityProtocolType]::Tls12
    注册PSRepository-默认-详细
    设置PSRepository-名称“PSGallery”-InstallationPolicy Trusted
    
    TLS 1.0和1.1最近也在NuGet.org上被弃用:
    但是。

    还有一件事没有提到。 你确实需要跑步

    notepad $profile
    
    并复制粘贴此位更改代理详细信息:

    [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
    

    但是,如果您启用了HTTPS检查,您可能希望将中间人证书添加到
    “受信任的根证书颁发机构”

    ,也可以查看一下,然后引用更好的部分将对您的答案有所帮助。)我已经看到这个答案提到了很多,但我在没有代理的家用电脑上出现了错误…同样的问题:+1用于来宾WiFi解决方案。有时,这只是为了让某些东西在企业环境中发挥作用而必须做的事情。最后一个对我有用!谢谢!