警告:无法find模块存储库

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

警告: 无法find模块存储库

我GOOGLE了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"但仍然失败。 我怎么能解决这个问题?

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

 PS C:\Windows\system32> Get-PSRepository Name InstallationPolicy SourceLocation ---- ------------------ -------------- PSGallery Untrusted https://www.powershellgallery.com/api/v2/