controls/job-historical-chart.ps1

function New-JobHistoricalChart {
    
    $JobsHistory = @()
    $Jobs = Get-UAJob
    $Jobs | ForEach-Object {
        if($_.Status -eq "Completed")
        {
            
            $JobScheduleObject = [PSCustomObject]@{
                Id       = $_.Id
                Script = $_.Script
                ScriptName = $_.Script.Name
                EndTime = $_.EndTime
                EndTimeTimeString = $_.EndTime | Get-Date -Format "yyyy-MM-dd HH"
            }

            $JobsHistory = $JobsHistory + $JobScheduleObject
        }
    }

 
    $JobsHistorySummary = $JobsHistory | Group-Object EndTimeTimeString


    New-UDChart -Type Bar -Endpoint {
        $JobsHistorySummary | Sort-Object -Property EndTime | 
            Select-Object -First 10 | 
            Out-UDChartData -DataProperty Count -LabelProperty Name -DatasetLabel "Jobs Run"
    }

}