如何使用 Start- AzureRmAutomationRunbook
powershell将哈希表传递给 azure child runbook cmdlet
?
我有两个运行手册,test1 和 test2:
workflow test1
{
$Conn = Get-AutomationConnection -Name AzureRunAsConnection
Add-AzureRMAccount -ServicePrincipal -Tenant $Conn.TenantID -ApplicationId $Conn.ApplicationID -CertificateThumbprint $Conn.CertificateThumbprint
$Hash = @{"ping"="pong"}
$parameterHash = @{"Hash"="$Hash"}
Start-AzureRmAutomationRunbook `
-ResourceGroupName "rg1" `
-AutomationAccountName "ac1" `
-Name "test2" `
-Parameters $parameterHash
}
workflow test2
{
Param
(
[Object]$Hash
)
"Result1:"
$Hash
InlineScript {
$Hash = $using:Hash
"Result2:"
$Hash
"Result3:"
foreach ($h in $Hash.GetEnumerator()) {
Write-Host "$($h.Name): $($h.Value)"
"Result4:"
$HashType = $Hash.GetType()
$HashType
}
}
}
当我运行 runbook test1 时,runbook test2 的结果是:
结果1:
System.Collections.Hashtable
结果2:
System.Collections.Hashtable
结果3:
结果4:
IsPublic IsSerial Name BaseType
PSComputerName
-------- -------- ---- -------- -------------- True True String System.Object 本地主机结果4:
True True 字符串
System.Object localhost结果4:
True True 字符串
System.Object localhost
这里出了什么问题?如何使用正确地将哈希表传递给 azure child runbook Start-AzureRmAutomationRunbook cmdlet
?
提前谢谢!
问候,克里斯