术语 'New-AzResourceGroupDeployment' 未被识别为 cmdlet、函数的名称

The term 'New-AzResourceGroupDeployment' is not recognized as the name of a cmdlet, function

我需要 运行 在我的 PowerShell 中执行以下命令:

New-AzResourceGroupDeployment 
    -Name Myrg1010 
    -ResourceGroupName ADFcslResourceGroup 
    -TemplateFile C:\ADFARM.json 
    -TemplateParameterFile C:\ADFARM-Parameters.json

在执行此命令之前 运行 我已连接到我的 Azure 订阅

Connect-AzAccount

但我有以下错误:

New-AzResourceGroupDeployment : The term 'New-AzResourceGroupDeployment' 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
+ New-AzResourceGroupDeployment -Name MyARMDeployment -ResourceGroupNam ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (New- 
   AzResourceGroupDeployment:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

我找到了这个 但这不是我的情况,因为我的 powershell 版本是 5.1.2

Directory: C:\Program Files\WindowsPowerShell\Modules


ModuleType Version    Name                                ExportedCommands
---------- -------    ----                                ----------------
Script     5.1.2      Azure                               {Get- 
AzureAutomationCertificate, Get-AzureAutomationConnection, New-AzureAuto...

你能告诉我我该怎么做吗?

您需要安装 Azure Powershell 模块:

您可以只为这个命令寻找一个:

Install-Module -Name Az.Resources -AllowClobber -Scope CurrentUser

或全部:

Install-Module -Name Az -AllowClobber -Scope CurrentUser

详情见here

每当出现cmdlet错误时,需要检查是否安装了模块,如评论中所述,尝试安装

Install-Module -Name Az -AllowClobber -Scope CurrentUser

Az Module