Hello,
I have amended the existing report and I managed to throw 2 birds with one stone. For reference I paste the report for script task execution. It reports both the output as well as the exit code.
select
vc.name,
vc.Domain,
vc.[OS Name],
i.Name as 'Task Name',
eti.Result,
ti.ExecutedBy,
ti.StartTime,
replace(replace(replace(replace(cast(to2.Value as NVarchar(max)), '/',''), 'string', ''), 'int', ''),'<>','') as [Output],
ti.Name as 'Task Instance Name'
from TaskInstanceSummaries ti
left join TaskInstanceParents tip on tip.ParentTaskInstanceGuid = ti.TaskInstanceGuid
left join TaskOutputPropertyValue to2 on to2.TaskInstanceGuid = tip.TaskInstanceGuid
join ItemVersions iv on iv.VersionGuid = ti.TaskVersionGuid -- Find the name of the task
join Item i on i.Guid = iv.ItemGuid
join Evt_Task_Instances eti on eti.TaskInstanceguid = tip.TaskInstanceGuid
join vComputer vc on vc.guid = eti._ResourceGuid
where i.Name = 'Windows 10 Setup with Compatibility Scan'
and to2.Name = 'scriptoutput'
order by ti.StartTime desc
I hope it helps others having the same dilema.
regads,
Tomasz