How to pass hash table to azure child runbook using Start-AzureRmAutomationRunbook
powershell cmdlet
?
I have two runbooks, test1 and 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
}
}
}
When I run runbook test1, the result of runbook test2 is:
Result1:
System.Collections.Hashtable
Result2:
System.Collections.Hashtable
Result3:
Result4:
IsPublic IsSerial Name BaseType
PSComputerName
-------- -------- ---- -------- -------------- True True String System.Object localhostResult4:
True True String
System.Object localhostResult4:
True True String
System.Object localhost
What is going wrong here? How do I properly pass a hash table to a azure child runbook using Start-AzureRmAutomationRunbook cmdlet
?
Thanx in advance!
Regards, Chris