【发布时间】:2021-03-21 20:21:39
【问题描述】:
我可以使用 azure automation runbook(powershell) 来运行驻留在 VM 中的 Powershell。只要 VM Powershell 不需要任何参数,它就可以正常工作。如果我们将参数从运行手册发送到 VM powershell,则它不起作用。 VM powershell 接收参数为空。 Runbook 没有其他问题。 这是传递参数的方式。
$runcmdparameters=
@{"name" = "EXE"}
Out-File -InputObject $ScriptToRun -FilePath ScriptToRun.ps1
Invoke-AzVMRunCommand -AsJob -ResourceGroupName $RG-Name -Name $myName-CommandId 'RunPowerShellScript' -ScriptPath ScriptToRun.ps1 -Parameter $runcmdparameters -Verbose
这是在VM-powershell-script中接收参数的方式
[CmdletBinding()]
param (
[Parameter(Position=0)]
[string]$name
)
【问题讨论】:
标签: azure powershell azure-automation