无法找到模块提供者 [英] Unable to find module providers
问题描述
我在使用 PowerShell 时遇到问题.几乎就像它没有完全安装一样;这很奇怪,因为它是 Windows 10 并且随附.
I'm having an issue with PowerShell. It's almost like it's not installed all the way; which is weird since it's Windows 10 and it ships with it.
在没有锁定的情况下,我尝试用另一台正在运行的 Windows 10 机器上的新副本替换以下目录:
With no lock, I've tried replacing the following directories with a fresh copy from another Windows 10 machine that is working:
- C:\Users\UserName\AppData\Local\PackageManagement
- C:\Program Files\WindowsPowerShell
- C:\Program Files (x86)\WindowsPowerShell
- C:\Windows\System32\WindowsPowerShell
我也试过SFC/scannow
,但没有发现任何问题.我已经搜索了几个小时,但找不到任何有完全相同问题的人.有人有什么想法吗?
I also tried SFC /scannow
, but it found no issues. I've searched for hours and haven't been able to find anyone with the exact same issue. Does anyone have any ideas?
PS C:\WINDOWS\system32> [environment]::OSVersion.Version
Major Minor Build Revision
----- ----- ----- --------
10 0 10586 0
<小时>
PS C:\WINDOWS\system32> $PSVersionTable.PSVersion
Major Minor Build Revision
----- ----- ----- --------
5 0 10586 122
<小时>
错误:
PS C:\WINDOWS\system32> Get-PSRepository
PackageManagement\Get-PackageSource : Unable to find module providers (PowerShellGet).
At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:3544 char:31
+ ... ckageSources = PackageManagement\Get-PackageSource @PSBoundParameters
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidArgument:(Microsoft.Power...etPackageSource:GetPackageSource) [Get-PackageSource
], Exception
+ FullyQualifiedErrorId : UnknownProviders,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPackageSource
<小时>
PS C:\WINDOWS\system32> Get-PackageProvider -Name PSModule -ForceBootstrap
Get-PackageProvider : Unable to find package provider 'PSModule'. It may not be imported yet. Try 'Get-PackageProvider
-ListAvailable'.
At line:1 char:1
+ Get-PackageProvider -Name PSModule -ForceBootstrap
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Microsoft.Power...PackageProvider:GetPackageProvider) [Get-PackageProvi
der], Exception
+ FullyQualifiedErrorId : UnknownProviderFromActivatedList,Microsoft.PowerShell.PackageManagement.Cmdlets.GetPacka
geProvider
下面什么都不返回:
PS C:\WINDOWS\system32> Get-PackageProvider -ListAvailable
PS C:\WINDOWS\system32>
推荐答案
看起来我解决了这个问题.我使用 CMD.exe 方法安装了 Chocolatey.
Looks like I solved the issue. I installed Chocolatey by using the CMD.exe method.
我以管理员身份运行 CMD.exe 并运行以下命令:
I ran CMD.exe as an administrator and ran the following command:
@powershell -NoProfile -ExecutionPolicy Bypass -Command "iex ((new-object net.webclient).DownloadString('https://chocolatey.org/install.ps1'))" && SET PATH=%PATH%;%ALLUSERSPROFILE%\chocolatey\bin
现在我有一个 PS 存储库:PS C:\WINDOWS\system32> 获取-PSRepository
Now I have a PS Repository: PS C:\WINDOWS\system32> Get-PSRepository
Name PackageManagementProvider InstallationPolicy SourceLocation
---- ------------------------- ------------------ --------------
PSGallery NuGet Untrusted https://www.powershellgallery.com/api/v2/
我猜在安装 Chocolatey 的过程中发生了一些事情,修复了损坏的任何东西.
I'm guessing something during the install of Chocolatey, repaired whatever was broken.
这篇关于无法找到模块提供者的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!