gpt4 book ai didi

powershell - Install-PackageProvider 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称

转载 作者:行者123 更新时间:2023-12-03 11:25:40 27 4
gpt4 key购买 nike

我关注 Get Started with the PowerShell Gallery这表明 PowerShellGet 模块存在于 Windows 10(我正在使用 - build 14721)中。为了确认,我正在运行 PowerShell v5:

>$PSVersionTable

Name Value
---- -----
PSVersion 5.0.14271.1000
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0...}
BuildVersion 10.0.14271.1000
CLRVersion 4.0.30319.42000
WSManStackVersion 3.0
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1

Get Started with the PowerShell Gallery状态:

PowerShellGet also requires the NuGet provider to work with the PowerShell Gallery. You will be prompted to install the NuGet provider automatically upon first use of PowerShellGet if the NuGet provider is not in one of the following locations: •$env:ProgramFiles\PackageManagement\ProviderAssemblies
•$env:LOCALAPPDATA\PackageManagement\ProviderAssemblies



我在这些位置没有任何东西:
>ls $env:LOCALAPPDATA\PackageManagement\ProviderAssemblies    
>ls $env:ProgramFiles\PackageManagement\ProviderAssemblies
ls : Cannot find path 'C:\Program Files\PackageManagement\ProviderAssemblies' because it does not exist.
At line:1 char:1
+ ls $env:ProgramFiles\PackageManagement\ProviderAssemblies
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (C:\Program File...viderAssemblies:String) [Get-ChildItem], ItemNotFoundException
+ FullyQualifiedErrorId : PathNotFound,Microsoft.PowerShell.Commands.GetChildItemCommand

Get Started with the PowerShell Gallery然后说:

Or, you can run Install-PackageProvider -Name NuGet -Force to automate the download and installation of the NuGet provider.



如果我尝试这样做:
>Install-PackageProvider -Name NuGet -Force
Install-PackageProvider : The term 'Install-PackageProvider' is not recognized as the name of a cmdlet, function, script file, or operable program.
correct and try again.
At line:1 char:1
+ Install-PackageProvider -Name NuGet -Force
+ ~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Install-PackageProvider:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

我很困惑。我有 PowerShell v5,但似乎我没有应该有的一切,即 PowerShellGet。

有人可以解释为什么吗?

最佳答案

直到 PowerShell 5.1 才引入“Install-PackageProvider”

关于powershell - Install-PackageProvider 未被识别为 cmdlet、函数、脚本文件或可运行程序的名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35818432/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com