| | | 1 | | <# |
| | | 2 | | .SYNOPSIS |
| | | 3 | | Returns the full schedule report. |
| | | 4 | | .DESCRIPTION |
| | | 5 | | This function retrieves the current schedule report, including all scheduled jobs and their next run times. |
| | | 6 | | .PARAMETER Server |
| | | 7 | | The Kestrun host object containing the scheduler. |
| | | 8 | | .PARAMETER TimeZoneId |
| | | 9 | | Optional Windows / IANA time-zone id to convert timestamps. |
| | | 10 | | Example: "Pacific Standard Time" or "Europe/Berlin" |
| | | 11 | | .PARAMETER AsHashtable |
| | | 12 | | If set, returns a hashtable instead of a ScheduleReport object. |
| | | 13 | | .EXAMPLE |
| | | 14 | | Get-KrScheduleReport -Server $myServer |
| | | 15 | | Retrieves the schedule report from the specified Kestrun server. |
| | | 16 | | .EXAMPLE |
| | | 17 | | Get-KrScheduleReport -Server $myServer -TimeZoneId "Europe/Berlin" |
| | | 18 | | Retrieves the schedule report with timestamps converted to the specified time zone. |
| | | 19 | | .OUTPUTS |
| | | 20 | | Returns a ScheduleReport object or a hashtable if AsHashtable is set. |
| | | 21 | | #> |
| | | 22 | | function Get-KrScheduleReport { |
| | | 23 | | [KestrunRuntimeApi('Everywhere')] |
| | | 24 | | [CmdletBinding()] |
| | | 25 | | [OutputType([Kestrun.Scheduling.ScheduleReport])] |
| | | 26 | | [OutputType([Hashtable])] |
| | | 27 | | param( |
| | | 28 | | [Parameter(Mandatory = $false, ValueFromPipeline = $true)] |
| | | 29 | | [Kestrun.Hosting.KestrunHost]$Server, |
| | | 30 | | [string]$TimeZoneId, |
| | | 31 | | [switch]$AsHashtable |
| | | 32 | | ) |
| | | 33 | | begin { |
| | | 34 | | # Ensure the server instance is resolved |
| | 0 | 35 | | $Server = Resolve-KestrunServer -Server $Server |
| | | 36 | | } |
| | | 37 | | process { |
| | 0 | 38 | | if (-not $Server.Scheduler) { |
| | 0 | 39 | | throw 'SchedulerService is not enabled.' |
| | | 40 | | } |
| | | 41 | | |
| | 0 | 42 | | $tz = if ($TimeZoneId) { |
| | 0 | 43 | | [TimeZoneInfo]::FindSystemTimeZoneById($TimeZoneId) |
| | 0 | 44 | | } else { [TimeZoneInfo]::Utc } |
| | | 45 | | |
| | 0 | 46 | | if ($AsHashtable) { |
| | 0 | 47 | | return $Server.Scheduler.GetReportHashtable($tz) |
| | | 48 | | } else { |
| | 0 | 49 | | return $Server.Scheduler.GetReport($tz) |
| | | 50 | | } |
| | | 51 | | } |
| | | 52 | | } |
| | | 53 | | |