Install-PackageProvider is not recognized as the name of a cmdlet, function, script file, or operating program

I will follow. It starts with the PowerShell gallery , which says that the PowerShellGet module exists in Windows 10 (which I use is build 14721). To confirm, I run 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 

Start with the PowerShell Gallery :

PowerShellGet also requires the NuGet provider to work with the PowerShell Gallery. The first time you use PowerShellGet, you will be asked to install the NuGet provider if the NuGet provider is not in one of the following locations: β€’ $ ENV: ProgramFiles \ PackageManagement \ ProviderAssemblies
β€’ $ ENV: LOCALAPPDATA \ PackageManagement \ ProviderAssemblies

I have nothing in these places:

 >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 

Start with the PowerShell Gallery , then specify:

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

If I try:

 >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 

I am very confused. I have PowerShell v5, but it seems that I do not have everything that should be there, namely PowerShellGet.

Can someone explain why?

+7
source share
2 answers

This error means that PowerShell cannot find the module that includes Install-PackageProvider. Install-PackageProvider is a member of the PackageManagement module. To verify this, run Get-Module

 Get-Module -ListAvailable -Name PackageManagement 

If these errors are missing, you need to make sure that the PackageManagement folder contains a folder inside your $ env: PSModulePath. Here you can quickly view each of the folders for the PackageManagement folder.

 $env:psmodulepath.Split(';') | foreach {gci $_ -filter '*packagemanagement*'} 

If nothing comes back, you don’t even have the PackageManagement package folder anywhere where it can be automatically imported by PowerShell.

If so, I recommend reinstalling PowerShell v5 RTM .

+2
source

"Install-PackageProvider" was not introduced before PowerShell 5.1

0
source

Source: https://habr.com/ru/post/1244494/


All Articles