获取 AzureAutomationJob CreationTime 类型

Get-AzureAutomationJob CreationTime Type

当我在 Azure Automation 中 运行 这段代码时, CreationTime 的类型是 String。然而,当我在 Powershell ISE 中 运行 它时,类型是 DateTimeOffset。 这是为什么?:

$job = Get-AzureAutomationJob -Id '6edcaf79-f924-480d-9242-8c113206d7cb' -AutomationAccountName nonprodruntimebuild
$type = $job.CreationTime.GetType().Name
Write-Output $type

这是一个已知错误。 Azure 自动化 cmdlet 中返回的 DateTimeOffset 字段是 PowerShell 工作流中的字符串。解决方法是像这样将它们转换回 DateTimes:

$datetimeoffset = Get-Date $job.CreationTime