我正在尝试使用Azure自动化中的powershell脚本在Azure上创建VM . 此VM将从市场创建 . 所以我需要在我的脚本中使用cmdlet'Set-AzureRmVMPlan' .
$ vm = New-AzureRmVMConfig -VMName $ inVMName -VMSize $ vmSize Set-AzureRmVMPlan -VM $ vm -Publisher“kali-linux”-Product“kali-linux”-Name“kali”
当我从Powershell ISE运行它时,此脚本工作正常,但是当我将此命令放在Azure自动化Runbook中时,Azure无法识别此命令 . 我得到以下错误,
Set-AzureRmVMPlan:术语“Set-AzureRmVMPlan”未被识别为cmdlet,函数,脚本文件或可操作程序的名称 . 检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试 . 在restore-vhd-backups:8 char:8 CategoryInfo:ObjectNotFound:(Set-AzureRmVMPlan:String)[],CommandNotFoundException FullyQualifiedErrorId:CommandNotFoundException
所以我进一步调查,发现此命令在页面"Edit PowerShell Runbook"的cmdlet列表中不可用(见下图)
我还知道这个cmdlet是去年从Azure链接器添加到Azure Powershell中的
How to include "Plan information" when creating ARM VM from a captured image using Powershell?
有人可以帮我吗?
1 回答
那么,Azure Automation使用旧版本的模块,您必须转到Azure自动化刀片>资产>模块>浏览图库,然后重新导入AzureRM.Profile和AzureRM.Compute .