Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet

后端 未结 10 878
刺人心
刺人心 2020-12-14 05:50

I was trying to install Azure using Install-Module Azure in PowerShell. I got the following error:

PS C:\\Windows\\system32> Install-Module A         


        
相关标签:
10条回答
  • 2020-12-14 06:38

    I didn't have the NuGet Package Provider, you can check running Get-PackageProvider:

    PS C:\WINDOWS\system32> Get-PackageProvider 
    
    Name                     Version          DynamicOptions                                                                                                                 
    ----                     -------          --------------                                                                                                                 
    msi                      3.0.0.0          AdditionalArguments                                                                                                            
    msu                      3.0.0.0                                                                                                                                         
    NuGet  <NOW INSTALLED>   2.8.5.208        Destination, ...                             
    

    The solution was installing it by running this command:

    Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force
    

    If that fails with the error below you can copy/paste the NuGet folder from another PC (admin needed): C:\Program Files\PackageManagement\ProviderAssemblies\NuGet:

    WARNING: Unable to download from URI 'https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll' to ''.
    WARNING: Failed to bootstrap provider 'https://onegetcdn.azureedge.net/providers/nuget-2.8.5.208.package.swidtag'.
    WARNING: Failed to bootstrap provider 'nuget'.
    WARNING: The specified PackageManagement provider 'NuGet' is not available.
    PackageManagement\Install-PackageProvider : Unable to download from URI 
    'https://onegetcdn.azureedge.net/providers/Microsoft.PackageManagement.NuGetProvider-2.8.5.208.dll' to ''.
    At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\PSModule.psm1:6463 char:21
    +             $null = PackageManagement\Install-PackageProvider -Name $script:NuGe ...
    
    0 讨论(0)
  • 2020-12-14 06:39

    I have Windows 10 and PowerShell 5.1 was already installed. For whatever reason the x86 version works and can find "Install-Module", but the other version cannot.

    Search your Start Menu for "powershell", and find the entry that ends in "(x86)":

    Here is what I experience between the two different versions:

    0 讨论(0)
  • 2020-12-14 06:39

    Actually my solution to this problem was much simpler, because I already had the latest version of PowerShell and is still didn't recognize Install-Module command. What fixed the "issue" for me was just typing the command manually, since originally I tried copying the snippet from a website and apparently there was some issue with the formatting when copy&pasting, so when I typed the command manually it installed the module without any problem.

    0 讨论(0)
  • 2020-12-14 06:51

    I think the above answer posted by Jeremy Thompson is the correct one, but I don't have enough street cred to comment. Once I updated nuget and powershellget, Install-Module was available for me.

    Install-PackageProvider -Name NuGet -MinimumVersion 2.8.5.201 -Force 
    Install-PackageProvider -Name Powershellget -Force
    

    What is interesting is that the version numbers returned by get-packageprovider didn't change after the update.

    0 讨论(0)
提交回复
热议问题