< Summary - Kestrun — Combined Coverage

Information
Class: Public.Service.Add-KrTasks
Assembly: Kestrun.PowerShell.Public
File(s): /home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Service/Add-KrTasks.ps1
Tag: Kestrun/Kestrun@2d87023b37eb91155071c91dd3d6a2eeb3004705
Line coverage
0%
Covered lines: 0
Uncovered lines: 5
Coverable lines: 5
Total lines: 51
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 10/15/2025 - 01:01:18 Line coverage: 0% (0/5) Total lines: 51 Tag: Kestrun/Kestrun@7c4ce528870211ad6c2d2398c31ec13097fc5840

Metrics

File(s)

/home/runner/work/Kestrun/Kestrun/src/PowerShell/Kestrun/Public/Service/Add-KrTasks.ps1

#LineLine coverage
 1<#
 2.SYNOPSIS
 3    Adds ad-hoc Tasks support to the Kestrun server.
 4.DESCRIPTION
 5    Registers the Kestrun Task service on the server, enabling one-off script execution (PowerShell, C#, VB.NET)
 6    with status/result and cancellation support.
 7.PARAMETER Server
 8    The Kestrun server instance.
 9.PARAMETER MaxRunspaces
 10    Optional maximum PowerShell runspaces for task execution; falls back to scheduler sizing when omitted.
 11.PARAMETER PassThru
 12    Returns the server when specified.
 13.EXAMPLE
 14    Add-KrTasksService
 15    Adds the Tasks service to the default server.
 16.EXAMPLE
 17    $server = Add-KrTasksService -PassThru
 18    Adds the Tasks service and returns the server instance.
 19.NOTES
 20    Requires the Kestrun.Hosting.KestrunHost.AddTasks() method.
 21    If the Tasks service is already registered, this cmdlet has no effect.
 22    The Tasks service enables ad-hoc script execution via New-KrTask, Start-KrTask, Stop-KrTask, Remove-KrTask.
 23    The Tasks service uses PowerShell runspaces for PowerShell tasks; the MaxRunspaces parameter controls the maximum nu
 24#>
 25function Add-KrTasksService {
 26    [KestrunRuntimeApi('Definition')]
 27    [CmdletBinding()]
 28    [OutputType([Kestrun.Hosting.KestrunHost])]
 29    param(
 30        [Parameter(Mandatory = $false, ValueFromPipeline = $true)]
 31        [Kestrun.Hosting.KestrunHost]$Server,
 32
 33        [Parameter()]
 34        [int]$MaxRunspaces,
 35
 36        [Parameter()]
 37        [switch]$PassThru
 38    )
 39    begin {
 040        $Server = Resolve-KestrunServer -Server $Server
 41    }
 42    process {
 043        if ($PSBoundParameters.ContainsKey('MaxRunspaces')) {
 044            $Server.AddTasks($MaxRunspaces) | Out-Null
 45        } else {
 046            $Server.AddTasks() | Out-Null
 47        }
 48
 049        if ($PassThru) { return $Server }
 50    }
 51}

Methods/Properties

Add-KrTasksService()