Powershell 错误提示库不可用稍后再试

标签 powershell

我遇到了无法安装任何模块的问题。即使当我尝试注册时,我也会收到此错误。任何解决此问题的想法都值得赞赏。

PS C:\Users\abc> Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable.  Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4095 char:9
+         Get-PSGalleryApiAvailability -Repository $Name
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
    + FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability
 
Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1
+ Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
    + FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository
 

PS C:\Users\abc> $PSVersionTable

Name                           Value                                                                                                                                                                 
----                           -----                                                                                                                                                                 
PSVersion                      5.1.17134.858                                                                                                                                                         
PSEdition                      Desktop                                                                                                                                                               
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                                                                                               
BuildVersion                   10.0.17134.858                                                                                                                                                        
CLRVersion                     4.0.30319.42000                                                                                                                                                       
WSManStackVersion              3.0                                                                                                                                                                   
PSRemotingProtocolVersion      2.3                                                                                                                                                                   
SerializationVersion           1.1.0.1                                                                                                                                                               
-- 添加更多命令
Find-PackageProvider -Name nuget
WARNING: Unable to download from URI 'https://go.microsoft.com/fwlink/?LinkID=627338&clcid=0x409' to ''.
WARNING: Unable to download the list of available providers. Check your internet connection.
Find-PackageProvider : No match was found for the specified search criteria and package name 'nuget'. Try
Get-PackageSource to see all available registered package sources.
At line:1 char:1
+ Find-PackageProvider -Name nuget
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Microsoft.Power...PackageProvider:FindPackageProvider) [Find-PackagePro
   vider], Exception
    + FullyQualifiedErrorId : NoMatchFoundForCriteria,Microsoft.PowerShell.PackageManagement.Cmdlets.FindPackageProvid
   er
注册似乎已完成,没有任何错误,但没有添加任何内容
PS C:\Users\abc> Register-PSRepository -Default
PS C:\Users\abc> Get-PSRepository
WARNING: Unable to find module repositories.
PS C:\Users\abc>
PS C:\Users\abc> [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12
PS C:\Users\abc> Register-PSRepository -Name PSGallery -SourceLocation https://www.powershellgallery.com/api/v2
Get-PSGalleryApiAvailability : PowerShell Gallery is currently unavailable.  Please try again later.
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4095 char:9
+         Get-PSGalleryApiAvailability -Repository $Name
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [Get-PSGalleryApiAvailability], InvalidOperationException
    + FullyQualifiedErrorId : PowerShellGalleryUnavailable,Get-PSGalleryApiAvailability

Register-PSRepository : Use 'Register-PSRepository -Default' to register the PSGallery repository.
At line:1 char:1
+ Register-PSRepository -Name PSGallery -SourceLocation https://www.pow ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (PSGallery:String) [Register-PSRepository], ArgumentException
    + FullyQualifiedErrorId : UseDefaultParameterSetOnRegisterPSRepository,Register-PSRepository

PS C:\Users\abc> Get-PSRepository
WARNING: Unable to find module repositories.

最佳答案

尝试强制 tls 1.2。这解决了大多数 powershell 图库问题[Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12

关于Powershell 错误提示库不可用稍后再试,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64011123/

相关文章:

c# - 在 powershell 和 C# 之间共享变量

powershell - 如何将 VSCode 添加到 PowerShell 的路径?

Powershell:如何将 bool 值传递给函数参数?

powershell - 自托管 gitlab 运行器。 PATH 环境变量的内容与常规 powershell 不同

string - 如何将 URL 字符串拆分/解析为对象?

powershell - 删除数组的最后一个字符

.net - 如何选择正确的 "network place"图标?

powershell - 让 psessions 为 txt 文件中列出的多个服务器正确循环时出现问题

Azure 存储 - 使用 PowerShell 上传 .zip 文件

powershell - PowerShell 中 Get-ADUser 多行筛选器的反引号