Install-Module : The term 'Install-Module'

2019-01-25 02:12发布

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

PS C:\Windows\system32> Install-Module Azure
Install-Module : The term 'Install-Module' is not recognized as the name of a cmdlet, function, script file, 
or operable program. Check the spelling of the name, or if a path was included, verify that the path is corre
ct and try again.
At line:1 char:1
+ Install-Module Azure
+ ~~~~~~~~~~~~~~
    + CategoryInfo          : ObjectNotFound: (Install-Module:String) [], CommandNotFoundException
    + FullyQualifiedErrorId : CommandNotFoundException

Why is PS not recognizing the basic Install module? Without this I can't even install Azure. What should I do?

5条回答
成全新的幸福
2楼-- · 2019-01-25 02:44

You should install the latest version of PowerShell, then use this command Install-Module Azure to install azure module. Because from Powershell 5.0 onwards you , you will be able to use the cmdlet to Install-Module, Save-Module

PS > $psversiontable
Name                           Value
----                           -----
PSVersion                      5.1.14393.576
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.14393.576
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

More information about install Azure PowerShell, refer to the link.

查看更多
\"骚年 ilove
3楼-- · 2019-01-25 02:53

Another GUI based option to fix this error is to download the PackageManagement PowerShell Modules (msi installer) from Microsoft website and install the modules.

Once this is installed you will not get "'Install-Module' is not recognized as the name of a cmdlet" error.

查看更多
三岁会撩人
4楼-- · 2019-01-25 03:04

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.

查看更多
ゆ 、 Hurt°
5楼-- · 2019-01-25 03:06

If you are trying to install a module that is listed on the central repository for PS content called PowerShell Gallery, you need to install PowerShellGet. Then the command will be available. I'm currently using PS 4.0. Installing PowerShellGet did the trick for me.

Source:

With the latest PowerShellGet module, you can:

  • Search through items in the Gallery with Find-Module and Find-Script
  • Save items to your system from the Gallery with Save-Module and Save-Script
  • Install items from the Gallery with Install-Module and Install-Script
  • Upload items to the Gallery with Publish-Module and Publish-Script
  • Add your own custom repository with Register-PSRepository

Another great article to get started with PS Gallery.

查看更多
Anthone
6楼-- · 2019-01-25 03:11

Since you are using the lower version of PS:

What you can do in your case is you first download the module in your local folder.

Then, there will be a .psm1 file under that folder for this module.

You just

import-Module "Path of the file.psm1"

Here is the link to download the Azure Module: Azure Powershell

This will do your work.

查看更多
登录 后发表回答