< Summary - Kestrun — Combined Coverage

Information
Class: Public.SharedState.Get-KrSharedState
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SharedState/Get-KrSharedState.ps1
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
100%
Covered lines: 5
Uncovered lines: 0
Coverable lines: 5
Total lines: 49
Line coverage: 100%
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 11/19/2025 - 17:40:50 Line coverage: 60% (3/5) Total lines: 49 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02604/08/2026 - 23:41:36 Line coverage: 100% (5/5) Total lines: 49 Tag: Kestrun/Kestrun@971dd53fc1f17b61ce476aa4cec36c172d4f02e4

Coverage delta

Coverage delta 40 -40

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SharedState/Get-KrSharedState.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Retrieves the value of a previously defined global variable.
 4.DESCRIPTION
 5    Looks up a variable in the Kestrun global variable table and returns its
 6    value. If the variable does not exist, `$null` is returned.
 7.PARAMETER Server
 8    The Kestrun server instance.
 9.PARAMETER Global
 10    If specified, the variable is retrieved from the global shared state.
 11.PARAMETER Name
 12    Name of the variable to retrieve.
 13    This should be the fully qualified name of the variable, including any
 14    namespaces.
 15.EXAMPLE
 16    Get-KrSharedState -Name "MyVariable"
 17    This retrieves the value of the global variable "MyVariable".
 18.NOTES
 19    This function is part of the Kestrun.SharedState module and is used to retrieve the value of global variables.
 20#>
 21function Get-KrSharedState {
 22    [KestrunRuntimeApi('Everywhere')]
 23    [CmdletBinding(defaultParameterSetName = 'Server')]
 24    param(
 25        [Parameter(ValueFromPipeline = $true, ParameterSetName = 'Server')]
 26        [Kestrun.Hosting.KestrunHost]$Server,
 27
 28        [Parameter(Mandatory = $true, ParameterSetName = 'Global')]
 29        [switch]$Global,
 30
 31        [Parameter(Mandatory)]
 32        [string]$Name
 33    )
 34    begin {
 135        if (-not $Global.IsPresent) {
 36            # Ensure the server instance is resolved
 137            $Server = Resolve-KestrunServer -Server $Server
 38        }
 39    }
 40    process {
 141        if ($Global.IsPresent) {
 42            # Retrieve from server instance
 143            return [Kestrun.SharedState.GlobalStore]::Get($Name)
 44        }
 45        # Retrieve (or $null if not defined)
 146        return $Server.SharedState.Get($Name)
 47    }
 48}
 49

Methods/Properties

Get-KrSharedState()