< 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@0d738bf294e6281b936d031e1979d928007495ff
Line coverage
0%
Covered lines: 0
Uncovered lines: 9
Coverable lines: 9
Total lines: 59
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 11/14/2025 - 12:29:34 Line coverage: 0% (0/9) Total lines: 59 Tag: Kestrun/Kestrun@5e12b09a6838e68e704cd3dc975331b9e680a626

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 {
 039        if (-not $Global.IsPresent) {
 40            # Ensure the server instance is resolved
 041            $Server = Resolve-KestrunServer -Server $Server
 42        }
 43    }
 44    process {
 045        if ($Global.IsPresent) {
 46            # Remove from global store
 047            if ($PSCmdlet.ShouldProcess("Global shared state variable '$Name'", "Remove")) {
 048                return [Kestrun.SharedState.GlobalStore]::Remove($Name)
 49            }
 050            return $false
 51        }
 52        # Remove from server instance
 053        if ($PSCmdlet.ShouldProcess("Shared state variable '$Name' on server '$($Server.Name)'", "Remove")) {
 054            return $Server.SharedState.Remove($Name)
 55        }
 056        return $false
 57    }
 58}
 59

Methods/Properties

Remove-KrSharedState()