Kestrun

PowerShell brains. Kestrel speed

Kestrun jumpstarts your web automation with a fast, PowerShell-centric framework built on ASP.NET Core, blending scriptable flexibility with modern .NET performance.

Get started now View it on GitHub


Kestrun is a PowerShell-integrated framework on ASP.NET Core (Kestrel) designed for REST API development. It combines the performance of C# with the flexibility of PowerShell, making it easy to prototype, automate, and deliver production-ready APIs with confidence.

Highlights

  • PowerShell-first routing — author endpoints with Add-KrMapRoute or Razor+PS hybrids.
  • Auth built-ins — JWT bearer, API keys, Basic, Windows/Negotiate, client certs.
  • Razor + PS — serve .cshtml with .ps1 backers.
  • Scheduling — PowerShell and C# jobs with cron-like control.
  • Logging — Serilog, syslog, REST; structured logs galore.
  • OpenAPI — generate specs and serve interactive docs (Swagger UI / ReDoc / Scalar / RapiDoc / Elements).
  • Realtime — SSE and SignalR support for push-style apps.
  • Localization — Request-based culture resolution with .psd1 or JSON string tables and per-key fallback across culture hierarchies.
  • Extended HTTP verbs — includes WebDAV methods and HTTP QUERY (OpenAPI 3.2+) when you need a body-based search.

Getting started

Minimal example

# spin up Kestrun
Import-Module Kestrun
New-KrServer -Name 'MyKestrunServer'
Add-KrEndpoint -Port 5000
Enable-KrConfiguration

Add-KrMapRoute -Verbs Get -Path '/ps/hello' -ScriptBlock {
    Write-KrTextResponse -InputObject "Hello world" -StatusCode 200
}
Add-KrMapRoute -Verbs Get -Path '/cs/hello' -Code @'
    Context.Response.WriteTextResponse("Hello world", 200);
'@ -Language CSharp

Start-KrServer

OpenAPI example

# A minimal OpenAPI 3.1 example with a single endpoint
Import-Module Kestrun
# Create a new Kestrun server
New-KrServer -Name 'MyKestrunServer'
# Add an endpoint on port 5000
Add-KrEndpoint -Port 5000

#  Define OpenAPI info
Add-KrOpenApiInfo -Title 'Hello World API' `
    -Version '1.0.0' `
    -Description 'A simple OpenAPI 3.1 example with a single endpoint.'

Enable-KrConfiguration

<#
.SYNOPSIS
    Get greeting message.
.DESCRIPTION
    Returns a simple greeting message.
#>
function getGreeting {
    [OpenApiPath(HttpVerb = 'Get' , Pattern = '/greeting' )]
    param()
    Write-KrTextResponse -Text 'Hello, World!' -StatusCode 200
}

Start-KrServer

External Documentation