[英]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-AzureRmAccount
是AzureRM.Profile
模塊的一部分。 當我進入模塊文件夾時,我看到AzureRM.Profile
已列出。 為了獲得這些模塊,我運行了Install-Module -name AzureRM
和Import-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
列出的路徑之一看到帶有nupkg
的AzureRM.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.