这是一个常见的错误,但我在互联网上找到的通用解决方案无法解决它。
运行Get-PsRepository、Install-Module和相关命令(OneGet?)时会抛出“无法找到模块提供程序(PowerShellGet)”错误。这似乎是NuGet包管理器模块的问题,但我不知道该如何恢复。安装的包提供程序似乎有效。
症状模式:
C:> [Net.ServicePointManager] :: SecurityProtocol
Tls12
获取-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4496 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
使用-默认-详细注册-PSRepository
VERBOSE: PowerShell meta provider initialization failed.
VERBOSE: No match was found for the specified search criteria and provider name 'PowerShellGet'. Try
'Get-PackageProvider -ListAvailable' to see if the provider exists on the system.
PackageManagement\Register-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:4211 char:17
+ ... $null = PackageManagement\Register-PackageSource @PSBoundParamete ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power...erPackageSource:RegisterPackageSource) [Register-Pac
kageSource], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.RegisterPackageSource
安装模块PowerShellGet -Force
PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1809 char:21
+ ... $null = PackageManagement\Install-Package @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument: (Microsoft.Power....InstallPackage:InstallPackage) [Install-Package], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.InstallPackage
事实:
Windows 10 (1903)
Powershell版本为5.1.18362.1171
以管理员身份运行PowerShell
未在代理后面
可以访问https://www.powershellgallery.com/api/v2
可以访问nuget.org
`[Net.ServicePointManager]::SecurityProtocol = Tls12
FIPS已禁用(HKLM\System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled DWORD=0)
Get-PackageProvider只显示NuGet 2.8.5.208
PowerShellGet版本为1.0.0.1;尝试使用Install-Module PowerShellGet -Force进行SXS安装时,遇到相同的错误信息:PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).