未将术语“ New-AzResourceGroupDeployment”识别为cmdlet函数的名称

时间:2019-10-31 15:20:01

标签: azure powershell azure-resource-group

我需要在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

我发现了这个article,但事实并非如此,因为我的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...

您能告诉我该怎么办吗?

2 个答案:

答案 0 :(得分:3)

您需要安装Azure Powershell模块:

您只能在此命令中找到一个:

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

或全部:

Install-Module -Name Az -AllowClobber -Scope CurrentUser

有关详情,请参见here

答案 1 :(得分:2)

每当收到cmdlet错误时,都需要检查模块是否已安装,如注释中所述,请尝试安装

Install-Module -Name Az -AllowClobber -Scope CurrentUser

Az Module