I found a weird behaviour in Azure automation, if you use “New-Object PSObject” it runs perfectly fine when the script is executed directly (via the portal or the Powershell command “Start-AzureRmAutomationRunbook”). However if you try and do an inline call from another workbook it fails and errors out with something like:
1 2 |
<strong class="azc-log-stream-error">New-Object PSObject –Property $CurrentProperties </strong> |
the code i used initially was (snippet):
1 2 |
$CurrentProperties = @{Veriable1=$_.var1;Color="red"} $AllObjects += New-Object PSObject –Property $CurrentProperties |
It seems like this command is no longer supported or runs correctly when the child workbook is called by another workbook. To get around this i recommend using the Powershell v3 method which works perfectly:
1 |
$AllObjects += [PSCustomObject]@{Veriable1=$_.var1;Color="red"} |