< Summary - Kestrun — Combined Coverage

Information
Class: Public.SharedState.Remove-KrSharedState
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/SharedState/Remove-KrSharedState.ps1
Tag: Kestrun/Kestrun@5f1d2b981c9d7292c11fd448428c6ab6c811c5de
Line coverage
88%
Covered lines: 8
Uncovered lines: 1
Coverable lines: 9
Total lines: 59
Line coverage: 88.8%
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: 0% (0/9) Total lines: 59 Tag: Kestrun/Kestrun@fcf33342333cef0516fe0d0912a86709874fd02604/08/2026 - 23:41:36 Line coverage: 88.8% (8/9) Total lines: 59 Tag: Kestrun/Kestrun@971dd53fc1f17b61ce476aa4cec36c172d4f02e4

Coverage delta

Coverage delta 89 -89

Metrics

File(s)

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

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Removes a global variable from Kestrun shared state.
 4.DESCRIPTION
 5    Deletes a variable from the Kestrun global variable table.
 6    If the variable does not exist, no action is taken.
 7.PARAMETER Server
 8    The Kestrun server instance.
 9.PARAMETER Global
 10    If specified, the variable is removed from the global shared state.
 11.PARAMETER Name
 12    Name of the variable to remove.
 13.PARAMETER WhatIf
 14    Shows what would happen if the command runs. The command is not run.
 15.PARAMETER Confirm
 16    Prompts you for confirmation before running the command. The command is not run unless you respond
 17    affirmatively.
 18.EXAMPLE
 19    Remove-KrSharedState -Name "MyVariable"
 20    This removes the global variable "MyVariable".
 21.NOTES
 22    This function is part of the Kestrun.SharedState module and is used to remove global variables.
 23#>
 24function Remove-KrSharedState {
 25    [KestrunRuntimeApi('Everywhere')]
 26    [CmdletBinding(defaultParameterSetName = 'Server', SupportsShouldProcess = $true, ConfirmImpact = 'Medium')]
 27    [OutputType([bool])]
 28    param(
 29        [Parameter(ValueFromPipeline = $true, ParameterSetName = 'Server')]
 30        [Kestrun.Hosting.KestrunHost]$Server,
 31
 32        [Parameter(Mandatory = $true, ParameterSetName = 'Global')]
 33        [switch]$Global,
 34
 35        [Parameter(Mandatory)]
 36        [string]$Name
 37    )
 38    begin {
 139        if (-not $Global.IsPresent) {
 40            # Ensure the server instance is resolved
 141            $Server = Resolve-KestrunServer -Server $Server
 42        }
 43    }
 44    process {
 145        if ($Global.IsPresent) {
 46            # Remove from global store
 147            if ($PSCmdlet.ShouldProcess("Global shared state variable '$Name'", "Remove")) {
 148                return [Kestrun.SharedState.GlobalStore]::Remove($Name)
 49            }
 150            return $false
 51        }
 52        # Remove from server instance
 253        if ($PSCmdlet.ShouldProcess("Shared state variable '$Name' on server '$($Server.Name)'", "Remove")) {
 154            return $Server.SharedState.Remove($Name)
 55        }
 056        return $false
 57    }
 58}
 59

Methods/Properties

Remove-KrSharedState()