Plugins
Plugins that extend the PowerShell Universal platform.
Plugins are functionality that are not enabled by default. A publicly available plugin API is currently being developed and will be released with a future version of PowerShell Universal. Below are a list of the plugins that are shipped with PowerShell Universal v4.2 and later.
Enabling Plugins
Plugins are enabled in appsettings.json
or through environment variables. See App Settings for information on where to configure these options. Any changes made to the configuration will require a restart of the PowerShell Universal service.
C# API Environment
Identifier: PowerShellUniversal.Language.CSharp
This plugin creates a C#-based environment that can be used to create API endpoints with C# code. APIs created with C# are much faster than PowerShell-based endpoints. Endpoints run directly in the PowerShell Universal service. Any exception thrown from your endpoint will be handled and a valid status code will be returned to the caller.
You must create endpoints with the -Path parameter and specify the C#
environment for the endpoint to function properly.
Defining an Endpoint
Within the C# endpoint, there are two classes that are of interest. The first is the request
variable that is passed to the endpoint. It is an ApiRequest
object.
In your endpoint, you can access this variable automatically.
The endpoint must return an ApiResponse
object. This object has the following definition.
You can return a response by creating a new object and returning it from your endpoint.
You can access the PowerShell Universal service container within your endpoint by accessing the ServiceProvider
property in your endpoint. We currently do not document the internal services of PowerShell Universal.
OpenTelemetry
Identifier: PowerShellUniversal.Plugins.OpenTelemetry
OpenTelemetry is a collection of APIs, SDKs, and tools. Use it to instrument, generate, collect, and export telemetry data (metrics, logs, and traces) to help you analyze your software’s performance and behavior.
The plugin enables integration with the technology. You can use App Settings to configure where to send data. PowerShell Universal currently only exposes a single OTLP endpoint configuration. The below configuration would work with Prometheus.
YARP
Identifier: PowerShellUniversal.Plugins.YARP
YARP (Yet Another Reverse Proxy) is a Microsoft project that allows ASP.NET Core applications to act as reverse proxies. PowerShell Universal only exposes this configuration but does not extend it in many regards. You can use App Settings to configure the proxy and starting the PSU service will enable the YARP functionality. Follow the YARP articles to understand how to configure the service.
The one extension that we do provide into YARP is the ability to specify a PSU role that is required for a particular proxy route. For example, the following would enforce the Administrator role.
You can replace the Administrator
portion of the policy name to enforce a different role. For example: ExecutorRolePolicy
.
Last updated