< Summary - Kestrun — Combined Coverage

Information
Class: Public.Server.Set-KrServerNamedPipeOptions
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Set-KrServerNamedPipeOptions.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 23
Coverable lines: 23
Total lines: 101
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 09/08/2025 - 20:34:03 Line coverage: 0% (0/20) Total lines: 100 Tag: Kestrun/Kestrun@3790ee5884494a7a2a829344a47743e0bf492e7209/09/2025 - 20:36:29 Line coverage: 0% (0/25) Total lines: 105 Tag: Kestrun/Kestrun@eec6e531f6ea893bb4939db76943e009d9fd963c10/13/2025 - 16:52:37 Line coverage: 0% (0/23) Total lines: 101 Tag: Kestrun/Kestrun@10d476bee71c71ad215bb8ab59f219887b5b4a5e

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Server/Set-KrServerNamedPipeOptions.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Sets the named pipe options for a Kestrun server instance. (Windows Operating Systems only)
 4.DESCRIPTION
 5    This function sets the named pipe options for the specified Kestrun server instance, allowing for configuration of v
 6.PARAMETER Server
 7    The Kestrun server instance to configure. This parameter is mandatory and must be a valid server object.
 8.PARAMETER Options
 9    The NamedPipeTransportOptions object containing the desired named pipe configuration settings.
 10    This parameter is mandatory when using the 'Options' parameter set.
 11.PARAMETER ListenerQueueCount
 12    Specifies the number of named pipe listener queues to create for the server. This parameter is optional and can be s
 13.PARAMETER MaxReadBufferSize
 14    Specifies the maximum size, in bytes, of the read buffer for named pipe connections. This parameter is optional and 
 15.PARAMETER CurrentUserOnly
 16    If specified, the named pipe will only be accessible by the current user. This parameter is optional and can be left
 17.PARAMETER MaxWriteBufferSize
 18    Specifies the maximum size, in bytes, of the write buffer for named pipe connections. This parameter is optional and
 19.PARAMETER PipeSecurity
 20    Specifies the PipeSecurity object to apply to the named pipe. This parameter is optional and can be set to a specifi
 21.PARAMETER PassThru
 22    If specified, the cmdlet will return the modified server instance after applying the named pipe options.
 23.OUTPUTS
 24    [Kestrun.Hosting.KestrunHost]
 25    The modified Kestrun server instance with the updated named pipe options.
 26.EXAMPLE
 27    Set-KrServerNamedPipeOptions -Server $server -ListenerQueueCount 5 -MaxReadBufferSize 65536
 28    This command sets the named pipe options for the specified Kestrun server instance, configuring the listener queue c
 29.EXAMPLE
 30    Set-KrServerNamedPipeOptions -Server $server -CurrentUserOnly
 31    This command configures the named pipe options for the specified Kestrun server instance to restrict access to the c
 32.NOTES
 33    This function is for Windows Operating Systems only, as named pipes are not supported on Unix-based systems.
 34    The named pipe options will be applied to the server's options and will be used when the server is started to listen
 35    The named pipe transport options can be configured to optimize performance and security based on the specific requir
 36    The named pipe transport options can be set either by providing a complete NamedPipeTransportOptions object
 37    This function is designed to be used in the context of a Kestrun server setup and allows for flexible configuration 
 38#>
 39function Set-KrServerNamedPipeOptions {
 40    [KestrunRuntimeApi('Definition')]
 41    [Diagnostics.CodeAnalysis.SuppressMessageAttribute('PSUseShouldProcessForStateChangingFunctions', '')]
 42    [CmdletBinding(defaultParameterSetName = 'Items')]
 43    param(
 44        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 45        [Kestrun.Hosting.KestrunHost]$Server,
 46        [Parameter(Mandatory = $true, ParameterSetName = 'Options')]
 47        [Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions]$Options,
 48        [Parameter( ParameterSetName = 'Items')]
 49        [int]$ListenerQueueCount,
 50        [Parameter( ParameterSetName = 'Items')]
 51        [long]$MaxReadBufferSize,
 52        [Parameter( ParameterSetName = 'Items')]
 53        [switch]$CurrentUserOnly,
 54        [Parameter( ParameterSetName = 'Items')]
 55        [long]$MaxWriteBufferSize,
 56        [Parameter( ParameterSetName = 'Items')]
 57        [System.IO.Pipes.PipeSecurity]$PipeSecurity,
 58        [Parameter()]
 59        [switch]$PassThru
 60    )
 61    begin {
 062        if (-not $IsWindows) {
 063            Write-Warning 'This function is for Windows Operating Systems only, as named pipes are not supported nativel
 64        }
 65        # Ensure the server instance is resolved
 066        $Server = Resolve-KestrunServer -Server $Server
 67    }
 68    process {
 069        if ($PSCmdlet.ParameterSetName -eq 'Items') {
 070            $Options = [Microsoft.AspNetCore.Server.Kestrel.Transport.NamedPipes.NamedPipeTransportOptions]::new()
 071            if ($null -ne $ListenerQueueCount) {
 072                Write-KrLog -Logger $Server.Logger -Level Verbose -Message "Setting NamedPipeOptions.ListenerQueueCount 
 073                $options.ListenerQueueCount = $ListenerQueueCount
 74            }
 075            if ($null -ne $MaxReadBufferSize) {
 076                Write-KrLog -Logger $Server.Logger -Level Verbose -Message "Setting NamedPipeOptions.MaxReadBufferSize t
 077                $options.MaxReadBufferSize = $MaxReadBufferSize
 78            }
 079            if ($CurrentUserOnly.IsPresent) {
 080                Write-KrLog -Logger $Server.Logger -Level Verbose -Message "Setting NamedPipeOptions.CurrentUserOnly to 
 081                $Options.CurrentUserOnly = $true
 82            }
 083            if ($null -ne $MaxWriteBufferSize) {
 084                Write-KrLog -Logger $Server.Logger -Level Verbose -Message "Setting NamedPipeOptions.MaxWriteBufferSize 
 085                $Options.MaxWriteBufferSize = $MaxWriteBufferSize
 86            }
 087            if ($null -ne $PipeSecurity) {
 088                Write-KrLog -Logger $Server.Logger -Level Verbose -Message "Setting NamedPipeOptions.PipeSecurity to {Pi
 089                $Options.PipeSecurity = $PipeSecurity
 90            }
 91        }
 92
 093        $Server.Options.NamedPipeOptions = $Options
 94
 095        if ($PassThru.IsPresent) {
 96            # if the PassThru switch is specified, return the modified server instance
 097            return $Server
 98        }
 99    }
 100}
 101

Methods/Properties

Set-KrServerNamedPipeOptions()