Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

  • the JobScheduler PowerShell Module
  • a reporting PowerShell Module. This example makes use of the ImportExcel PowerShell Module that can be used to create Excel® reports on Windows and Linux.

The Get-JobSchedulerDailyPlanJobSchedulerTaskHistory cmdlet is used to retrieve daily plan task history items and to forward them to the ImportExcel module within a job. Two flavors of the job are available for Windows and Linux. The difference is not about the handling of cmdlets or parameters but due to the fact that PowerShell is invoked differently on Windows and Linux. For Windows environments usually PowerShell is available with the OS, for Linux the job has to call pwsh to invoke the PowerShell.

...

Code Block
languagepowershell
titleTask History Report (Windows version)
linenumberstrue
collapsetrue
<?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
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}} `
                | Export-Excel -Path /tmp/jobscheduler_reporting.xlsx -WorksheetName "Task-History" -ClearSheet;
				
Write-Output ".. report created: /tmp/jobscheduler_reporting.xls";
]]></script>
  <run_time/>
</job>

...