< Summary - Kestrun — Combined Coverage

Information
Class: Public.Server.Get-KrServer
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Get-KrServer.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 10
Coverable lines: 10
Total lines: 71
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 10/15/2025 - 21:27:26 Line coverage: 0% (0/10) Total lines: 71 Tag: Kestrun/Kestrun@c33ec02a85e4f8d6061aeaab5a5e8c3a8b665594

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Get-KrServer.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Gets the current Kestrun server instance.
 4.DESCRIPTION
 5    This function retrieves the current Kestrun server instance. If a server instance is not provided,
 6    it attempts to resolve the server from the current context.
 7.PARAMETER Server
 8    The Kestrun server instance to retrieve. If not specified, the function will attempt to resolve the current server c
 9.PARAMETER StartTime
 10    If specified, returns the server's start time as a DateTime object.
 11.PARAMETER StopTime
 12    If specified, returns the server's stop time as a DateTime object.
 13.PARAMETER Uptime
 14    If specified, returns the server's uptime as a TimeSpan object.
 15.EXAMPLE
 16    Get-KrServer
 17    This command retrieves the current Kestrun server instance.
 18.EXAMPLE
 19    Get-KrServer -StartTime
 20    This command retrieves the start time of the current Kestrun server instance.
 21.EXAMPLE
 22    Get-KrServer -StopTime
 23    This command retrieves the stop time of the current Kestrun server instance.
 24.EXAMPLE
 25    Get-KrServer -Uptime
 26    This command retrieves the uptime of the current Kestrun server instance.
 27.OUTPUTS
 28    [Kestrun.Hosting.KestrunHost]
 29        The current Kestrun server instance.
 30    [DateTime]
 31        The server's start time or stop time if the corresponding switch is used.
 32    [TimeSpan]
 33        The server's uptime if the Uptime switch is used.
 34.NOTES
 35    This function is part of the Kestrun PowerShell module and is used to manage Kestrun server instances.
 36    If the server instance is not found in the context, it attempts to resolve it using the Resolve-KestrunServer functi
 37#>
 38function Get-KrServer {
 39    [KestrunRuntimeApi('Everywhere')]
 40    [CmdletBinding(defaultParameterSetName = 'Default')]
 41    [OutputType([Kestrun.Hosting.KestrunHost])]
 42    [OutputType([DateTime])]
 43    [OutputType([TimeSpan])]
 44    param(
 45        [Parameter(ValueFromPipeline)]
 46        [Kestrun.Hosting.KestrunHost]$Server,
 47        [Parameter(ParameterSetName = 'StartTime')]
 48        [switch]$StartTime,
 49        [Parameter(ParameterSetName = 'StopTime')]
 50        [switch]$StopTime,
 51        [Parameter(ParameterSetName = 'Uptime')]
 52        [switch]$Uptime
 53    )
 54    process {
 055        if ($null -eq $Context -or $null -eq $Context.Response) {
 056            $Server = Resolve-KestrunServer -Server $Server
 57        } else {
 058            $Server = $Context.Host
 59        }
 60
 061        if ($StartTime.IsPresent) {
 062            return $Server.StartTime
 063        } elseif ($StopTime.IsPresent) {
 064            return $Server.StopTime
 065        } elseif ($Uptime.IsPresent) {
 066            return $Server.Uptime
 67        } else {
 068            return $Server
 69        }
 70    }
 71}

Methods/Properties

Get-KrServer()