< Summary - Kestrun — Combined Coverage

Information
Class: Public.Scheduling.Get-KrScheduleSnapshot
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Scheduling/Get-KrScheduleSnapshot.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 14
Coverable lines: 14
Total lines: 70
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Coverage history

Coverage history 0 25 50 75 100 08/26/2025 - 01:25:22 Line coverage: 0% (0/13) Total lines: 65 Tag: Kestrun/Kestrun@07f821172e5dc3657f1be7e6818f18d6721cf38a09/04/2025 - 18:11:31 Line coverage: 0% (0/13) Total lines: 66 Tag: Kestrun/Kestrun@de99e24698289f3f61ac7b73e96092732ae12b0509/08/2025 - 20:34:03 Line coverage: 0% (0/16) Total lines: 73 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7210/13/2025 - 16:52:37 Line coverage: 0% (0/14) Total lines: 70 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Scheduling/Get-KrScheduleSnapshot.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Returns a snapshot of the current schedule.
 4    .DESCRIPTION
 5        This function retrieves the current schedule snapshot, including all scheduled jobs and their next run times.
 6    .PARAMETER Server
 7        The Kestrun host object containing the scheduler.
 8    .PARAMETER Name
 9        Optional job name filter. If specified, only jobs matching the name will be returned.
 10    .PARAMETER TimeZoneId
 11        Optional Windows / IANA time-zone id to convert timestamps.
 12        Example: "Pacific Standard Time"  or  "Europe/Berlin"
 13    .PARAMETER AsHashtable
 14        If set, returns a hashtable instead of a ScheduleReport object.
 15    .EXAMPLE
 16        Get-KrScheduleSnapshot -Server $myServer
 17        Retrieves the schedule snapshot from the specified Kestrun server.
 18    .EXAMPLE
 19        Get-KrScheduleSnapshot -Server $myServer -Name 'Cache'
 20        Retrieves the schedule snapshot for the job named 'Cache'.
 21    .EXAMPLE
 22        Get-KrScheduleSnapshot -Server $myServer -TimeZoneId "Europe/Berlin"
 23        Retrieves the schedule snapshot with timestamps converted to the specified time zone.
 24    .EXAMPLE
 25        Get-KrScheduleSnapshot -Name 'ps-*' -TimeZoneId 'Pacific Standard Time'
 26        Retrieves all jobs matching the pattern 'ps-*' with timestamps converted to Pacific Standard Time.
 27    .OUTPUTS
 28        Returns a ScheduleReport object or a hashtable if AsHashtable is set.
 29#>
 30function Get-KrScheduleSnapshot {
 31    [KestrunRuntimeApi('Everywhere')]
 32    [CmdletBinding()]
 33    [OutputType([Kestrun.Scheduling.JobInfo[]])]
 34    [OutputType([Hashtable])]
 35    param(
 36        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 37        [Kestrun.Hosting.KestrunHost]$Server,
 38        [string[]]$Name,
 39        [string]$TimeZoneId,
 40        [switch]$AsHashtable
 41    )
 42    begin {
 43        # Ensure the server instance is resolved
 044        $Server = Resolve-KestrunServer -Server $Server
 45    }
 46    process {
 047        $jobs = $Server.Scheduler.GetSnapshot()
 48
 049        if (-not $AsHashtable) {
 050            return $jobs          # strongly-typed JobInfo records
 51        }
 52
 53        # PowerShell-friendly shape
 054        return $jobs | ForEach-Object {
 055            [ordered]@{
 056                Name = $_.Name
 057                LastRunAt = $_.LastRunAt
 058                NextRunAt = $_.NextRunAt
 059                IsSuspended = $_.IsSuspended
 60            }
 61        }
 62
 063        $tz = if ($TimeZoneId) {
 064            [TimeZoneInfo]::FindSystemTimeZoneById($TimeZoneId)
 065        } else { [TimeZoneInfo]::Utc }
 66
 067        $Server.Scheduler.GetSnapshot($tz, $AsHashtable, $Name)
 68    }
 69}
 70

Methods/Properties

Get-KrScheduleSnapshot()