17

I'm following Get Started with the PowerShell Gallery which states that the PowerShellGet module exists in Windows 10 (which I am using - build 14721). To confirm, I am running 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 states:

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

I don't have anything in those locations:

>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 then states:

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

If I try that:

>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'm very confused. I have PowerShell v5 but it seems I don't have everything that's supposed to be there, namely PowerShellGet.

Can someone explain why?

8
  • Are you running the Powershell console as Administrator? By default I believe the PS console or ISE is run as a limited user. Try right clicking Powershell from the Start menu and choose Run as Administrator. Commented Mar 5, 2016 at 19:06
  • Just tried running "Install-PackageProvider -Name NuGet -Force" as admin, same result :(
    – jamiet
    Commented Mar 5, 2016 at 19:07
  • Does your PS Console title say Administrator:? Also, have you checked technet.microsoft.com/en-us/library/mt676543.aspx and tried using Get-PackageProvider -ListAvailable when I try in PS v5 on Win 7, I get an error indicating ListAvailable is not a recognized param. Commented Mar 5, 2016 at 19:21
  • Just rebooting to install an update. Will let you know.
    – jamiet
    Commented Mar 5, 2016 at 19:21
  • >Get-PackageProvider -ListAvailable Get-PackageProvider : A parameter cannot be found that matches parameter name 'ListAvailable'.
    – jamiet
    Commented Mar 5, 2016 at 20:51

5 Answers 5

10

When I did Get-Module -ListAvailable -Name PackageManagement, as Adam Bertram suggested, I found that there was a different version in my home folder, cruft from a previous install of Windows that got copied across to a new machine:

> Get-Module -ListAvailable -Name PackageManagement


    Directory: C:\Users\<myusername>\Documents\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     1.4.7      PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa...


    Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Binary     1.0.0.1    PackageManagement                   {Find-Package, Get-Package, Get-PackageProvider, Get-Packa..

Deleting this version, or before that just forcing the system version to be used with Import-Module PackageManagement -RequiredVersion 1.0.0.1, allowed me to get the NuGet provider installed.

5

"Install-PackageProvider" was not introduced until PowerShell 5.1

3

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

Get-Module -ListAvailable -Name PackageManagement

If this errors out, you'll need to ensure you have the PackageManagement folder a folder inside of your $env:PSModulePath. Here's a quick way to look through 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 module folder anywhere where it can be auto-imported by PowerShell.

If that's the case, I'd recommend to reinstall PowerShell v5 RTM.

6
  • 1
    Thanks Adam, have upgraded to Windows 10 build 13279 and am getting the same symptoms. Have visited your link (microsoft.com/en-us/download/details.aspx?id=50395) and (not surprisingly) there's no option to download WMF5.0 for Windows 10. Am now utterly stumped.
    – jamiet
    Commented Mar 5, 2016 at 20:49
  • oh, and: >Get-PackageProvider -ListAvailable Get-PackageProvider : A parameter cannot be found that matches parameter name 'ListAvailable'.
    – jamiet
    Commented Mar 5, 2016 at 20:52
  • You'd likely have to use Add/Remove programs and Features to remove PowerShell or WMF5.0 since it would be an OS bundled component. Commented Mar 5, 2016 at 20:58
  • Yeah, that feels a bit dangerous. Think I'm just gonna have to downgrade to latest publicly available Win10, I'm on the fast ring for updates and am willing to bet that's part of the problem.
    – jamiet
    Commented Mar 5, 2016 at 21:03
  • Same problem for me. (Get-Module -ListAvailable -Name PackageManagement).ExportedCommands lists only Find-Package Get-Package Get-PackageProvider Get-PackageSource Install-Package Register-PackageSource Set-PackageSource Unregister-PackageSource Uninstall-Package Save-Package
    – TNT
    Commented Aug 23, 2016 at 17:16
0

I had to open up the folder Directory: C:\Users<myusername>\Documents\WindowsPowerShell\Modules

and rename/delete the PackageManagement folder Then everything started working more better.

0

On my Win2019, Get-PackageProvider (with capital letters) didn't work but get-packageprovider did. This Powershell that should be "the" solution always surprises me :-/

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.