Unable to find module providers

11,777

Solution 1

Looks like I solved the issue. I installed Chocolatey by using the CMD.exe method.

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

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/

I'm guessing something during the install of Chocolatey, repaired whatever was broken.

Solution 2

If your end goal is to install packages from Chocolatey or something similar with PowerShell you would want to perform the following.

To import the Module you would execute the following:

Import-Module PackageManagement

To install the package providers you would execute the following:

Install-PackageProvider -Name Chocolatey -Force

To find a package within the package provider Chocolatey you would execute the following (you could use wildcard for name to get all packages available):

Find-Package -Name SomePackageNameHere -ProviderName Chocolatey

Lastly, to install a package from Chocolatey you would execute the following:

Install-Package -Name SomePackageNameHere -ProviderName Chocolatey -Force

I hope this helps!

Share:
11,777
TB.
Author by

TB.

Updated on June 27, 2022

Comments

  • TB.
    TB. almost 2 years

    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.

    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

    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?

    System Information:

    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
    

    Errors:

    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
    

    The below returns nothing:

    PS C:\WINDOWS\system32> Get-PackageProvider -ListAvailable
    PS C:\WINDOWS\system32>