Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Corrupt PackageManager? Unable to find module providers (PowerShellGet)

This is a common error that is not solved by the common solutions I have found on the internet.

Unable to run Get-PsRepository, Install-Module, and related (OneGet?) commands without them throwing the "Unable to find module providers (PowerShellGet)" error. This appears to be an issue with the NuGet packagemanager module but I do not know how to recover. The package provider installed appears valid

Symptom patterns:
C:> [Net.ServicePointManager]::SecurityProtocol

Tls12

Get-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

Register-PSRepository -Default -Verbose

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  

Install-Module 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

Facts:
Windows 10 (1903)
Powershell 5.1.18362.1171
Running PowerShell as Administrator Not behind a proxy
Have access to https://www.powershellgallery.com/api/v2
Have access to nuget.org
`[Net.ServicePointManager]::SecurityProtocol = Tls12
FIPS is disabled (HKLM\System\CurrentControlSet\Control\Lsa\FIPSAlgorithmPolicy\Enabled DWORD=0)
Get-PackageProvider shows only NuGet 2.8.5.208
PowerShellGet version is 1.0.0.1 ; when trying force a sxs install with Install-Module PowerShellGet -Force I get the same: PackageManagement\Install-Package : Unable to find module providers (PowerShellGet).

like image 307
Killian Avatar asked Dec 28 '20 19:12

Killian


People also ask

Could not install NuGet provider install-module?

Solution for unable to install NuGet provider for PowerShell Run both cmdlets to set . NET Framework strong cryptography registry keys. After that, restart PowerShell and check if the security protocol TLS 1.2 is added. As of last, install the PowerShellGet module.

How do I register a PowerShell repository?

You can set the InstallationPolicy with the Set-PSRepository cmdlet. Specifies the name of the repository to register. You can use this name to specify the repository in cmdlets such as Find-Module and Install-Module . Specifies a OneGet package provider.

Why can't I find a specific module in PowerShell?

Probably it happened when network was not available. Get-PSRepository WARNING: Unable to find module repositories. Then restart PowerShell. Chocolatey installation should help too. PS C:\Windows\system3 2> Get-PSRepository WARNING: Unable to find module repositories.

What happened to the PowerShell Gallery update-module and install-module cmdlets?

With the deprecation of TLS 1.0 and 1.1 for PowerShell Gallery as of April 2020, the cmdlets Update-Module and Install-Module became broken. Thus, according to this article, some commands need to be executed to bring them alive again: TLS 1.0 and 1.1 were also recently deprecated at NuGet.org: But that was also previously announced.

What to do when package management is not working?

Removing the 1.4.7 package management folder from my document folder immediately (once i started a new shell) solved the issue!

What is the internal error State for the install-module?

The internal error state is 10013. Edit: Further investigation has revealed that the client library being used to fetch repo data is only capable of TLS 1.0, while the host invoking Install-Module was configured to only use TLS 1.2.


2 Answers

We encountered the same problem. Found this thread without a solution. But I dug a bit further and on the computer that had this problem we found version 1.4.7 of PackageManagement installed. After removing this everything started working normally. I have not found how this thing got installed. Seems like a legit powershell module from Microsoft but it's interacting with the 'normal' PowershellGet module and seems to break it. For us it was located in the %USERPROFILE%/document/WindowsPowershell/Modules. Also worth nothing that this %USERPROFILE% was a corporate OneDrive.

Edit: Microsoft have fixed this issue: https://github.com/PowerShell/vscode-powershell/issues/3432

like image 172
elangelo Avatar answered Oct 17 '22 03:10

elangelo


Not enough Rep to comment.

I ended up in the same situation. A Windows 10 1909 machine, with %USERPROFILE%/document being a corporate OneDrive. Moving PackageManagement out of /WindowsPowerShell/ changed Get-PSRepository's output from nothing to PSGallery. Thanks! – tmcg Mar 1 at 21:35 This was exactly the same issue. I suspect this is because PowerShell 7 dumped it into this location (possibly Visual Studio Code when it prompt to update?) – aolszowka Mar 1 at 22:09

I encountered the same issue with packagemanagement in %USERPROFILE%/documents on my personal profile. The file dates matched when I installed VScode and the Powershell Extensions on this new machine.

Removing the folder from modules corrected the issue for the time being.

like image 35
Redsloth55 Avatar answered Oct 17 '22 02:10

Redsloth55