Kestrun Module

Description

{{ Fill in the Description }}

Kestrun

Add-KrAntiforgeryMiddleware

Adds an Antiforgery service to the server.

Add-KrAntiforgeryTokenRoute

Adds a GET endpoint that issues the antiforgery cookie and returns a JSON token payload.

Add-KrApiDocumentationRoute

Adds a new API documentation route (Redoc or Swagger UI) to the Kestrun server.

Add-KrApiKeyAuthentication

Adds API key authentication to the Kestrun server.

Add-KrBasicAuthentication

Adds basic authentication to the Kestrun server.

Add-KrCacheMiddleware

Adds response caching to the Kestrun server.

Add-KrCacheResponse

Adds caching headers to the HTTP response.

Add-KrClaimPolicy

Adds a new claim policy to the KestrunClaims system.

Add-KrCommonAccessLogMiddleware

Adds Apache style common access logging to the Kestrun server.

Add-KrCompressionMiddleware

Adds response compression to the server.

Add-KrCookiesAuthentication

Adds cookie authentication to the Kestrun server.

Add-KrCorsPolicy

Adds a CORS policy to the Kestrun server.

Add-KrDistributedRedisCache

Adds StackExchange.Redis distributed cache services to the Kestrun server.

Add-KrDistributedSqlServerCache

Adds SQL Server distributed cache services to the Kestrun server.

Add-KrEndpoint

Creates a new Kestrun server instance with specified options and listeners.

Add-KrEnrichEnvironment

Adds environment information to the log context.

Add-KrEnrichErrorRecord

Enriches log events with ErrorRecord property if available.

Add-KrEnrichExceptionDetail

Adds exception details to the log context.

Add-KrEnrichFromLogContext

Enriches log events with properties from LogContext

Add-KrEnrichProcessId

Adds the process ID to the log context.

Add-KrEnrichProcessName

Adds the process name to the log context.

Add-KrEnrichProperty

Enriches log events with custom property.

Add-KrFaviconMiddleware

Adds a favicon to the Kestrun server.

Add-KrFileServerMiddleware

Registers a file server to serve static files from a specified path.

Add-KrForwardedHeader

Adds Forwarded Headers middleware to a Kestrun server.

Add-KrGitHubAuthentication

Adds GitHub OAuth (Authorization Code) authentication to the Kestrun server.

Add-KrHealthEndpoint

Registers the built-in aggregated health endpoint for the active Kestrun server.

Add-KrHealthHttpProbe

Registers an HTTP-based health probe that polls a remote endpoint.

Add-KrHealthProbe

Registers a script-based health probe with the active Kestrun server.

Add-KrHealthProcessProbe

Registers a health probe that executes an external process.

Add-KrHostFiltering

Adds Host Filtering middleware to a Kestrun server instance.

Add-KrHsts

Adds HTTP Strict Transport Security (HSTS) middleware to a Kestrun server instance.

Add-KrHtmlTemplateRoute

Adds a new HTML template route to the Kestrun server.

Add-KrHttpsRedirection

Adds HTTPS redirection middleware to the Kestrun server.

Add-KrJWTAudience

Adds an audience to the JWT token builder.

Add-KrJWTBearerAuthentication

Adds JWT Bearer authentication to the Kestrun server.

Add-KrJWTClaim

Adds a claim to the JWT token builder.

Add-KrJWTHeader

Adds a header to the JWT token builder.

Add-KrJWTIssuer

Adds an issuer to the JWT token builder.

Add-KrJWTSubject

Adds a subject to the JWT token builder.

Add-KrListenUnixSocket

Adds a Unix socket listener to a Kestrun server instance.

Add-KrMapRoute

Adds a new map route to the Kestrun server.

Add-KrNamedPipeListener

Adds a named pipe listener to a Kestrun server instance.

Add-KrOAuth2Authentication

Adds OAuth 2.0 (Authorization Code) authentication to the Kestrun server.

Add-KrOpenApiContact

Adds contact information to the OpenAPI document.

Add-KrOpenApiExternalDoc

Adds external documentation to the OpenAPI document.

Add-KrOpenApiInfo

Adds or updates the OpenAPI Info section in the specified OpenAPI documents.

Add-KrOpenApiLicense

Adds license information to the OpenAPI document.

Add-KrOpenApiRoute

Adds a new OpenAPI map route to the Kestrun server.

Add-KrOpenApiServer

Creates a new OpenAPI server.

Add-KrOpenApiTag

Adds a tag to the OpenAPI document.

Add-KrOpenIdConnectAuthentication

Adds OpenID Connect (Authorization Code) authentication to the Kestrun server.

Add-KrPowerShellRazorPagesRuntime

Adds PowerShell support for Razor Pages.

Add-KrRazorPageService

Adds Razor Pages service to the server.

Add-KrRouteGroup

Creates a grouped route context (prefix + shared options) for nested Add-KrMapRoute calls.

Add-KrScheduling

Adds scheduling support to the Kestrun server.

Add-KrScriptBlock

Adds a named scriptblock to the specified scope, allowing retrieval via a getter function.

Add-KrSession

Adds session state services and middleware to the Kestrun server.

Add-KrSignalRHubMiddleware

Maps a SignalR hub class to the given URL path.

Add-KrSinkConsole

Adds a console logging sink to the Kestrun logging system.

Add-KrSinkEventLog

Adds an Event Log sink to the Serilog logger configuration.

Add-KrSinkFile

Adds a file-based logging sink to the logging system.

Add-KrSinkHttp

Adds an HTTP sink to the Serilog logger configuration.

Add-KrSinkPowerShell

Adds a PowerShell sink to the logger configuration.

Add-KrSinkSyslogLocal

Adds a Syslog Local sink to the Serilog logger configuration.

Add-KrSinkSyslogTcp

Adds a Syslog TCP sink to the logging system.

Add-KrSinkSyslogUdp

Adds a Syslog UDP sink to the Serilog logger configuration.

Add-KrStaticFilesMiddleware

Registers a static file server to serve files from a specified path.

Add-KrTasksService

Adds ad-hoc Tasks support to the Kestrun server.

Add-KrUserClaim

Adds a claim to the current user. This function allows you to add a new claim to the current user’s identity. The claim can be of any type, and you must specify the claim type and value. The function will return the updated claims collection.

Add-KrWindowsAuthentication

Adds Windows authentication to the Kestrun server.

Build-KrClaimPolicy

Builds the claim policy configuration from the builder.

Build-KrJWT

Builds the JWT token from the builder.

Build-KrOpenApiDocument

Builds the OpenAPI document for the specified Kestrun server.

Clear-KrEnvironmentOverride

Clears any Kestrun environment override for the current PowerShell session.

Clear-KrSession

Clears all items from the session.

Close-KrLogger

Closes the logger and flushes all logs.

ConvertFrom-KrJwkJsonToCertificate

Creates a self-signed X509 certificate from an RSA JWK.

ConvertFrom-KrYaml

Converts a YAML string to a PowerShell object or hashtable.

ConvertTo-KrBase64Url

Converts a byte array to a Base64Url-encoded string.

ConvertTo-KrJwkJson

Converts an X509 certificate or RSA private key PEM to an RSA JWK JSON string.

ConvertTo-KrYaml

Converts a PowerShell object or hashtable to a YAML string.

Copy-KrJWTTokenBuilder

Creates a new cloned JWT token builder instance.

Enable-KrConfiguration

Enables Kestrun server configuration and starts the server.

Enable-KrExceptionHandling

Enables exception handling middleware for a Kestrun server instance.

Enable-KrStatusCodePage

Enables Status Code Pages for a Kestrun server.

Expand-KrObject

Expands an object into a formatted string for display.

Export-KrCertificate

Exports an X509Certificate2 to PFX or PEM(+key).

Export-KrOpenApiDocument

Exports the OpenAPI document for the specified Kestrun server in the desired format.

Get-KrBuiltTargetFrameworkVersion

Gets the target framework version that Kestrun was built against.

Get-KrCertificatePurpose

Lists the Enhanced Key Usage values on a certificate. This function is designed to be used in the context of Kestrun’s certificate management.

Get-KrDefaultLogger

Gets the logger for the current session.

Get-KrEnvironment

Gets the current Kestrun environment for the PowerShell session.

Get-KrFeatureSupport

Gets the support status of known features in the current Kestrun runtime environment.

Get-KrJwkThumbprint

Computes an RFC 7638 JWK thumbprint for an RSA key.

Get-KrJWTInfo

Retrieves information from a JWT token.

Get-KrJWTToken

Retrieves the JWT token from the builder result.

Get-KrJWTValidationParameter

Retrieves the validation parameters for a JWT token builder result.

Get-KrLoggerLevelSwitch

Gets the current logging level for a level switch.

Get-KrOpenApiDocument

Retrieves the OpenAPI document for the specified Kestrun server.

Get-KrRequestBody

Retrieves a request body value from the HTTP request.

Get-KrRequestCookie

Retrieves a cookie value from the HTTP request.

Get-KrRequestForm

Retrieves a request form value from the HTTP request.

Get-KrRequestHeader

Retrieves a request header value from the HTTP request.

Get-KrRequestQuery

Retrieves a query parameter value from the HTTP request.

Get-KrRequestRouteParam

Retrieves a request route value from the HTTP request.

Get-KrRoot

Retrieves the Kestrun root directory.

Get-KrScheduleReport

Returns the full schedule report.

Get-KrScheduleSnapshot

Returns a snapshot of the current schedule.

Get-KrServer

Gets the current Kestrun server instance.

Get-KrSessionByte

Retrieves a byte array value from the session by key.

Get-KrSessionInt32

Retrieves a 32-bit integer value from the session by key.

Get-KrSessionString

Retrieves a string value from the session by key.

Get-KrSharedState

Retrieves the value of a previously defined global variable.

Get-KrSignalRConnectedClient

Gets the number of connected SignalR clients.

Get-KrSinkJsonFormatter

Returns new instance of Serilog.Formatting.Json.JsonFormatter.

Get-KrTask

Gets the status or result of a task by id.

Get-KrTaskResult

Gets the detailed result of a task by id.

Get-KrTaskState

Gets the state of a task by id.

Get-KrVersion

Retrieves the Kestrun module version information.

Import-KrCertificate

Imports a PFX/PEM certificate file and returns X509Certificate2.

Initialize-KrRoot

Initializes the Kestrun root directory for path resolution.

Invoke-KrChallenge

Challenges the current request to authenticate with the specified authentication scheme.

Invoke-KrCookieSignIn

Signs in a user issuing an authentication cookie for the given scheme.

Invoke-KrCookieSignOut

Signs out the current user by removing their authentication cookie for the given scheme.

Invoke-KrWebRequest

Sends an HTTP request to a Kestrun server over various transport mechanisms (TCP, Named Pipe, Unix Socket).

Limit-KrJWTNotBefore

Sets the NotBefore time for the JWT token builder.

Limit-KrJWTValidity

Sets the validity period for the JWT token.

New-KrCertificateRequest

Creates a PEM-encoded CSR (and returns the private key).

New-KrClaimPolicy

Creates a new claim policy builder instance.

New-KrCookieBuilder

Creates and configures a new [Microsoft.AspNetCore.Http.CookieBuilder] instance.

New-KrCorsPolicyBuilder

Creates a new CORS policy builder.

New-KrJWTBuilder

Creates a new JWT token builder instance.

New-KrLogger

Creates a new instance of Serilog.LoggerConfiguration.

New-KrMapRouteOption

Creates a new instance of the Kestrun.Hosting.Options.MapRouteOptions class.

New-KrOpenApiExternalDoc

Creates a new OpenAPI external documentation object.

Creates a new OpenAPI Link object.

New-KrOpenApiServer

Creates a new OpenAPI server.

New-KrOpenApiServerVariable

Creates a new OpenAPI server variable.

New-KrPrivateKeyJwt

Builds a Private Key JWT (client assertion) for OAuth2/OIDC client authentication.

New-KrProbeResult

Creates a new Kestrun health ProbeResult object.

New-KrSelfSignedCertificate

Creates a new self-signed certificate.

New-KrServer

Creates a new Kestrun server instance.

New-KrTask

Creates a task without starting it.

Protect-KrJWT

Protects a JWT token using a specified secret or certificate.

Protect-KrJWTPayload

Encrypts the JWT payload using a secret, PEM file, or X509 certificate.

Push-KrLogContextProperty

Push a property into Serilog’s LogContext for the current scope.

Register-KrLogger

Starts the Kestrun logger.

Register-KrSchedule

Creates a new scheduled job in the active Kestrun host.

Remove-KrServer

Removes a Kestrun server instance.

Remove-KrSession

Removes a session item by key.

Remove-KrSharedState

Removes a global variable from Kestrun shared state.

Remove-KrTask

Removes a finished task from the registry.

Resolve-KrPath

Resolves a file path relative to the Kestrun root or a specified base path.

Resume-KrSchedule

Resumes a previously-paused schedule.

Send-KrSignalREvent

Broadcasts a custom event to all connected SignalR clients.

Send-KrSignalRGroupMessage

Broadcasts a message to a specific SignalR group.

Send-KrSignalRLog

Broadcasts a log message to all connected SignalR clients.

Set-KrCorsCredential

Set the CORS credentials policy for a given CorsPolicyBuilder object.

Set-KrCorsExposedHeader

Set exposed headers for a CORS policy builder.

Set-KrCorsHeader

Set CORS headers for a given CORS policy builder.

Set-KrCorsMethod

Sets the methods for a CORS policy in a .NET Core application.

Set-KrCorsOrigin

Sets the CORS origin for a given CorsPolicyBuilder object.

Set-KrCorsPreflightMaxAge

Sets the preflight max age for CORS policies in ASP.NET Core.

Set-KrDefaultLogger

Sets the logger for the current session.

Set-KrEnvironment

Sets the Kestrun environment for the current PowerShell session.

Set-KrLoggerLevel

Sets the minimum log level for the logger configuration.

Set-KrLoggerLevelSwitch

Sets the minimum logging level for a level switch.

Set-KrPythonRuntime

Selects which CPython runtime pythonnet will embed.

Set-KrServerHttpsOptions

Configures HTTPS options for a Kestrun server instance.

Set-KrServerLimit

Configures advanced options and operational limits for a Kestrun server instance.

Set-KrServerNamedPipeOptions

Sets the named pipe options for a Kestrun server instance. (Windows Operating Systems only)

Set-KrServerOptions

Configures advanced options and operational limits for a Kestrun server instance.

Set-KrSessionByte

Sets a byte array value in the session by key.

Set-KrSessionInt32

Sets a 32-bit integer value in the session by key.

Set-KrSessionString

Sets a string value in the session by key.

Set-KrSharedState

Defines or updates a global variable accessible across Kestrun scripts.

Set-KrTaskName

Sets the name and/or description of a task.

Start-KrServer

Starts the Kestrun server and listens for incoming requests.

Start-KrTask

Starts a previously created task by id.

Stop-KrServer

Starts the Kestrun server and listens for incoming requests.

Stop-KrTask

Requests cancellation for a running task.

Suspend-KrSchedule

Suspends a schedule, preventing it from running until resumed.

Test-KrCacheRevalidation

Checks request validators and writes 304 if appropriate; otherwise sets ETag/Last-Modified.

Test-KrCapability

Check if a specific feature is supported in the current Kestrun runtime environment.

Test-KrCertificate

Validates a certificate’s chain, EKU, and cryptographic strength.

Test-KrDebugContext

Tests if the current PowerShell session is in a debugging context.

Test-KrJWT

Validates a JWT token against the builder’s parameters.

Test-KrLogger

Tests if a logger exists or returns the current default logger for the session.

Test-KrOpenApiDocument

Tests the OpenAPI document for the specified Kestrun server.

Test-KrRoute

Tests if a route exists in the Kestrun host.

Update-KrJWT

Updates an existing JWT token.

Update-KrSynchronizedCounter

Updates a synchronized counter in a thread-safe manner.

Write-KrBinaryResponse

Writes binary data directly to the HTTP response body.

Write-KrBsonResponse

Writes an object serialized as BSON to the HTTP response.

Write-KrCborResponse

Writes an object serialized as CBOR to the HTTP response.

Write-KrCsvResponse

Writes CSV data to the HTTP response body.

Write-KrErrorResponse

Writes an error response to the HTTP client.

Write-KrFileResponse

Sends a file as the HTTP response.

Write-KrFormUrlEncodedResponse

Writes key/value data to the HTTP response body as application/x-www-form-urlencoded.

Write-KrHtmlResponse

Writes an HTML response to the HTTP response body.

Write-KrJsonResponse

Writes an object to the HTTP response body as JSON.

Write-KrLog

Logs a message with the specified log level and parameters.

Write-KrRedirectResponse

Writes a redirect response to the HTTP client.

Write-KrResponse

Writes a response with the specified input object and HTTP status code.

Write-KrStatusResponse

Sets only the HTTP status code for the response, without a body.

Write-KrStreamResponse

Writes a stream directly to the HTTP response body.

Write-KrTextResponse

Writes plain text to the HTTP response body.

Write-KrXmlResponse

Writes an object serialized as XML to the HTTP response.

Write-KrYamlResponse

Writes an object to the HTTP response body as YAML.