...
Find a sample report: jobscheduler_designed_report.xlsx
cmdlets
Code Block | ||||||||
---|---|---|---|---|---|---|---|---|
| ||||||||
$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 = "$env: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 |
...