GetType() 方法调用自动化变量的值导致 Runbook 失败并挂起

GetType() method call on Automation Variable's Value causing runbook to fail and suspend

我正在尝试在 Powershell.

类型的自动化运行手册中使用以下代码打印 Azure 自动化帐户的自动化变量值的类型
$var1 = ((Get-AzureRmAutomationVariable -Name "ArrayVar" -ResourceGroupName "automation-ps-rg" -AutomationAccountName "automation-ps-aa").Value).GetType()
$var1

我发现这会导致 Runbook 失败并重试 3 次,最终失败并显示以下消息。

Suspended
The runbook job was attempted 3 times, but it failed each time. 

这可能失败的原因是什么?

谢谢!

如果您只需要类型名称,请尝试 (...).GetType().FullName

将 System.Type 对象写入作业流似乎有些问题,因此请尝试 select 您真正感兴趣的属性,而不是整个对象。