我正在尝试从PowerShell中的Azure订阅中检索资源组名称:
Get-AzureRmResourceGroup | select resourcegroupname
但是我收到以下错误:
Get-AzureRmResourceGroup : The term 'Get-AzureRmResourceGroup' 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.
At line:1 char:1
+ Get-AzureRmResourceGroup | select resourcegroupname
+ ~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : ObjectNotFound: (Get-AzureRmResourceGroup:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
我有PowerShell 5.0并已导入最新的Azure模块。为什么不包含这个?
答案 0 :(得分:6)
您需要先使用以下命令安装Azure RM模块:
Install-Module AzureRM
然后您需要导入模块以供使用:
Import-Module AzureRM
答案 1 :(得分:4)
我错过了AzureRM依赖项,因此我必须运行以下命令:Install-AzureRM
。之后,Get-AzureRmResourceGroup | select resourcegroupname
成功执行。