< Summary - Kestrun — Combined Coverage

Information
Class: Public.Service.Add-KrPowerShellRuntime
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Service/Add-KrPowerShellRuntime.ps1
Tag: Kestrun/Kestrun@9d3a582b2d63930269564a7591aa77ef297cadeb
Line coverage
66%
Covered lines: 4
Uncovered lines: 2
Coverable lines: 6
Total lines: 49
Line coverage: 66.6%
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/Service/Add-KrPowerShellRuntime.ps1

#LineLine coverage
 1<#
 2    .SYNOPSIS
 3        Adds PowerShell runtime support to the Kestrun server.
 4    .DESCRIPTION
 5        This cmdlet allows you to register a PowerShell runtime with the Kestrun server.
 6        It can be used to execute PowerShell scripts and commands in the context of the Kestrun server.
 7    .PARAMETER Server
 8        The Kestrun server instance to which the PowerShell runtime will be added.
 9    .PARAMETER PassThru
 10        If specified, the cmdlet will return the modified server instance.
 11    .EXAMPLE
 12        $server | Add-KrPowerShellRuntime -PathPrefix '/ps'
 13        This example adds PowerShell runtime support to the server, with a path prefix of '/ps'.
 14    .EXAMPLE
 15        $server | Add-KrPowerShellRuntime
 16        This example adds PowerShell runtime support to the server without a path prefix.
 17    .NOTES
 18        This cmdlet is used to register a PowerShell runtime with the Kestrun server, allowing you to execute PowerShell
 19#>
 20function Add-KrPowerShellRuntime {
 21    [KestrunRuntimeApi('Definition')]
 22    [CmdletBinding()]
 23    [OutputType([Kestrun.Hosting.KestrunHost])]
 24    param(
 25        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 26        [Kestrun.Hosting.KestrunHost]$Server,
 27
 28        [Parameter()]
 29        [switch]$PassThru
 30    )
 31    begin {
 32        # Ensure the server instance is resolved
 133        $Server = Resolve-KestrunServer -Server $Server
 134        if ($null -eq $Server) {
 035            throw 'Server is not initialized. Please ensure the server is configured before setting options.'
 36        }
 37    }
 38    process {
 39
 240        $Server.AddPowerShellRuntime() | Out-Null
 41
 142        if ($PassThru.IsPresent) {
 43            # if the PassThru switch is specified, return the server instance
 44            # Return the modified server instance
 045            return $Server
 46        }
 47    }
 48}
 49

Methods/Properties

Add-KrPowerShellRuntime()