< 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@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
0%
Covered lines: 0
Uncovered lines: 16
Coverable lines: 16
Total lines: 73
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

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
 045        if ($null -eq $Server) {
 046            throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 47        }
 48    }
 49    process {
 050        $jobs = $Server.Scheduler.GetSnapshot()
 51
 052        if (-not $AsHashtable) {
 053            return $jobs          # strongly-typed JobInfo records
 54        }
 55
 56        # PowerShell-friendly shape
 057        return $jobs | ForEach-Object {
 058            [ordered]@{
 059                Name = $_.Name
 060                LastRunAt = $_.LastRunAt
 061                NextRunAt = $_.NextRunAt
 062                IsSuspended = $_.IsSuspended
 63            }
 64        }
 65
 066        $tz = if ($TimeZoneId) {
 067            [TimeZoneInfo]::FindSystemTimeZoneById($TimeZoneId)
 068        } else { [TimeZoneInfo]::Utc }
 69
 070        $Server.Scheduler.GetSnapshot($tz, $AsHashtable, $Name)
 71    }
 72}
 73

Methods/Properties

Get-KrScheduleSnapshot()