运行 通过 Azure 自动化调用 AzureRmVMRunCommand

Running Invoke-AzureRmVMRunCommand through Azure automation

我正在尝试 运行 通过来自 azure automation 的 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

您需要在使用之前安装模块:

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

简而言之:

转到模块
浏览图库
安装

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