2017-01-11 100 views
10

我試圖在PowerShell中使用Install-Module Azure安裝Azure。我得到了以下錯誤:安裝模塊:術語'安裝模塊'不被識別爲cmdlet的名稱

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 

爲什麼PS不能識別基本的安裝模塊?沒有這個我甚至不能安裝Azure。我該怎麼辦?

回答

5

由於您使用PS的低版本:

什麼,你可以在你的情況做的是你先下載模塊中的本地文件夾。

然後,該模塊將在該文件夾下有一個.psm1文件。

你剛纔

import-Module "Path of the file.psm1"

這裏是下載Azure的模塊的鏈接: Azure Powershell

這將做你的工作。

+0

你所說的 「下載模塊中的本地文件夾」 是什麼意思?我可以從網上下載嗎? – santafebound

+0

@santafebound:是的,當然,你可以從互聯網上下載的模塊。我認爲這是在Github上.. –

+1

@santafebound已經在那裏:我已經修改了答案,並給你GitHub的鏈接下載模塊.. :) –

5

您應該安裝最新版本的PowerShell,然後使用此命令Install-Module Azure安裝azure模塊。因爲從PowerShell的5.0起,你將能夠使用該cmdlet 安裝模塊,保存-模塊

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 

更多信息有關安裝Azure的PowerShell,請參閱link

+1

下面是PowerShell 5.0的鏈接https://www.microsoft.com/zh-cn/download/details.aspx?ID = 50395&TDUID =(7ad83b83d672d25d411f40a8991390ed)(266696)(1503186)(61836X1384699X8a8e7dfcb615c99305930ff07cd128e0)() –

0

如果您嘗試安裝名爲PowerShell Gallery的PS內容中央存儲庫上列出的模塊,則需要安裝PowerShellGet。然後該命令將可用。我目前正在使用PS 4.0。安裝PowerShellGet爲我做了訣竅。

Source

隨着最新PowerShellGet模塊,您可以:

  • 搜索通過與查找模塊和查找腳本在庫項目
  • 項目保存到您的系統免受圖庫使用保存模塊和保存腳本
  • 使用Install-Module和Install-Script從Gallery中安裝項目
  • 將項目上載到畫廊與發佈模塊和發佈腳本
  • 與註冊-PSRepository添加自己的自定義庫

Another great article to get started with PS Gallery.