Search code examples
powershellazureazure-automationpowershell-workflow

Get-AzureAutomationJob CreationTime Type


When I run this code in Azure Automation, the type of CreationTime is String. However when I run it in Powershell ISE, the type is DateTimeOffset. Why is this?:

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

Solution

  • It is a known bug. The DateTimeOffset fields returned in Azure Automation cmdlets are instead strings in PowerShell Workflow. The workaround is to convert them back to DateTimes like so:

    $datetimeoffset = Get-Date $job.CreationTime