...
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
<?xml version="1.0" encoding="UTF-8" ?> <job title="Report Task History" process_class="agent_windows"> <script language="powershell"><![CDATA[ Import-Module $env:SCHEDULER_DATA/config/powershell/Modules/ImportExcel; Import-Module $env:SCHEDULER_DATA/config/powershell/Modules/JobScheduler; Connect-JS -Url $JOCCockpitUrl -Credential $JOCCockpitCredential | Out-Null; # Dates in local timezone, output includes local date format $data = Get-JSTaskHistory -Timezone (Get-Timezone ) ` | Select-Object -Property @{name="JobScheduler ID"; expression={$_.jobschedulerId}}, ` @{name="Task ID"; expression={$_.taskId}}, ` @{name="Job"; expression={$_.job}}, ` @{name="Status"; expression={$_.state._text}}, ` @{name="Start Time"; expression={ Get-Date $_.startTime }}, ` @{name="End Time"; expression={ Get-Date $_.endTime }}, ` @{name="Duration (sec.)"; expression={ (New-Timespan -Start "$($_.startTime)" -End "$($_.endTime)").Seconds }}, ` @{name="Criticality"; expression={$_.criticality}}, ` @{name="Exit Code"; expression={$_.exitCode}} $xlfile = "/tmp\/TaskHistory.xlsx" Remove-Item $xlfile -ErrorAction SilentlyContinue $WorkSheetName = "TaskHistory" $excel = $data | Export-Excel $xlfile -ClearSheet -PassThru -AutoSize -AutoFilter -ConditionalText $( New-ConditionalText successful white green New-ConditionalText failed white Red New-ConditionalText Incomplete black orange) -WorksheetName $WorkSheetName -IncludePivotTable -PivotRows "Job" -PivotColumn "Status" -PivotData @{"status"="count"} ` -IncludePivotChart -ChartType ColumnClustered3D $pivotTableParams = @{ PivotTableName = "ByJob" Address = $excel.$WorkSheetName.cells["K1"] SourceWorkSheet = $excel.$WorkSheetName PivotRows = @("JobScheduler ID", "Job", "Status") PivotData = @{'Status' = 'count'} PivotTableStyle = 'Medium6' } $pt = Add-PivotTable @pivotTableParams -PassThru $pt.RowHeaderCaption = "By " + ($pivotTableParams.PivotRows -join ",") Close-ExcelPackage $excel -Show Write-Output ".. report created: /tmp/jobscheduler_reporting.xls"; ]]></script> <run_time/> </job> |
...