通过Azure自动化运行Invoke-AzureRmVMRunCommand

时间:2018-08-27 12:38:16

标签: powershell azure-automation

我正在尝试从azure自动化运行脚本Inrug Invoke-AzureRmVMRunCommand,但是它显示cmdlet不存在。请让我知道如何执行此操作。

脚本下方

Invoke-AzureRMVMRunCommand -ResourceGroup 'XXXXXX' -Name XXXXX-CommandID 'RunPowerShellScript' -ScriptPath 'Test.ps1'

错误详细信息。

Invoke-AzureRMVMRunCommand : The term 'Invoke-AzureRMVMRunCommand' 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
+ Invoke-AzureRMVMRunCommand -ResourceGroup 'olf3em-rds-mgmt' -Name OLF   ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo          : ObjectNotFound: (Invoke-AzureRMVMRunCommand:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException

2 个答案:

答案 0 :(得分:0)

您需要先安装模块,然后再使用这些模块:

https://docs.microsoft.com/en-us/azure/automation/automation-runbook-gallery#modules-in-powershell-gallery

简而言之:

转到模块
浏览图库
安装

答案 1 :(得分:0)

AzureRM.Compute模块中包含Invoke-AzureRmVMRunCommand命令。首先需要在自动化帐户中进行安装。