簡體   English   中英

盡管安裝了正確的模塊,但無法識別 Powershell cmdlet

[英]Powershell cmdlet is not recognized despite having the correct module installed

我正在嘗試運行 powerhsell 腳本(my_script)。 腳本存儲在桌面的this_folder中。 我正在使用C:\Users\me\desktop\this_folder>.\my_script在正確的路徑執行命令。 當我嘗試這樣做時,我得到了錯誤

The term 'Add-AzureRmAccount' 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 correct and try again

我知道Add-AzureRmAccountAzureRM.Profile模塊的一部分。 當我進入模塊文件夾時,我看到AzureRM.Profile已列出。 為了獲得這些模塊,我運行了Install-Module -name AzureRMImport-module AzureRM

任何想法可能會發生什么?

---更新---當我運行Get-Module命令時,我看到只列出了那個 AzureRM 模塊。 我試圖運行Install-Module -Name AzureRM.Profile並得到錯誤:

At C:\Program Files\WindowsPowerShell\Modules\PowerShellGet\1.0.0.1\PSModule.psm1:1772 char:21
+ ...          $null = PackageManagement\Install-Package @PSBoundParameters

因為我在$env:PSModulePath列出的路徑之一看到帶有nupkgAzureRM.Profile文件夾,所以我想我可以運行Import-Module -Name AzureRM.Profile並收到錯誤

import-module : The specified module 'AzureRM.Profile' was not 
loaded because no valid module file was found in any module directory.

有任何想法嗎?

您說您已經安裝並導入了 AzureRM 模塊,但是您是否已將 Azure 帳戶與Connect-AzureRmAccount cmdlet 連接起來? 我知道在與帳戶/訂閱建立活動連接之前,許多其他模塊不會公開所有可用的 cmdlet。

請注意,腳本可以忽略運行它們的上下文,因此您可能需要將以下內容添加到腳本的開頭:

Import-Module AzureRM
Connect-AzureRmAccount 

而不是在控制台中手動運行它們然后運行腳本。

您可能還想考慮使用 Az 模塊,因為 AzureRM 模塊即將退役,並且只會在 2020 年 12 月之前得到錯誤修復: 介紹新的 Azure PowerShell Az 模塊

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM