Did something change with the Job object that is sent on triggers?
I had a conditional, similar to the following, that suddenly stopped working: ($Job.Status -eq 'Completed')? 'True' : 'False')
I found out that it seems to have to do with the JobStatus enum becoming Deserialized.PowershellUniversal.JobStatus
, if I instead use the integer value of the Enum, it works fine.
A test trigger script that causes the issue looks like this:
param($Job)
@"
Job Status: $($Job.Status)
Job Status TypeNames: $($Job.Status.psobject.Typenames)
Job Status -eq 'Completed': $($Job.Status -eq 'Completed')
Job Status -eq 2: $($Job.Status -eq 2)
(Direct Cast to [PowershellUniversal.JobStatus]) Job Status -eq 'Completed': $([PowerShellUniversal.JobStatus]$Job.Status -eq 'Completed')
Switch Job Status: $(switch ($Job.Status) {
'Completed' { 'Branched on Completed' }
Default {'Default Branch'}
})
"@
Output is:
[information] Job Status: 2
Job Status TypeNames: Deserialized.PowerShellUniversal.JobStatus Deserialized.System.Enum Deserialized.System.ValueType Deserialized.System.Object
Job Status -eq 'Completed': False
Job Status -eq 2: True
(Direct Cast to [PowershellUniversal.JobStatus]) Job Status -eq 'Completed': True
Switch Job Status: Default Branch
I did fix it by direct casting, but it seems to have happened after the update to 3.7 (maybe 3.7.7 specifically?)
Product: PowerShell Universal
Version: 3.7.7