PowerShell Universal
DownloadsIssuesDiscordForums
v5
v5
  • ❓About
  • πŸ†•What's New in v5?
  • ⏯️Get Started
  • πŸ“ΊVideo Library
  • πŸ“šAdditional Resources
  • ⬇️Installation
    • Docker
    • Upgrade
    • Uninstall
    • Downgrade
    • Migrate and Restore
  • πŸ”‘Licensing
  • πŸ“ŠSystem Requirements
  • 🌐Supported Browsers
  • Cmdlet Help
  • πŸ”ŒAPI
    • About
    • Endpoints
    • OpenAPI
    • Event Hubs
    • Security
    • Error Handling
    • Rate Limiting
  • πŸ€–Automation
    • About Automation
    • Scripts
      • Parameters
    • Jobs
    • Schedules
    • Terminals
    • Tests
    • Triggers
  • πŸ“ŠApps
    • About
    • Apps
    • Components
      • Pages
      • Data Display
        • Alert
        • Badge
        • Chip
        • Data Grid
        • Date and Time
        • Icon
        • List
        • Markdown
        • Table
        • Timeline
        • Tooltip
        • Tree View
        • Typography
      • Data Visualization
        • Charts
        • Image
        • Map
      • Feedback
        • Backdrop
        • Modal
        • Progress
        • Skeleton
      • Inputs
        • Autocomplete
        • Button
        • Checkbox
        • Code Editor
        • Date Picker
        • Editor
        • Floating Action Button
        • Form
        • Radio
        • Rating
        • Select
        • Slider
        • Switch
        • Textbox
        • Time Picker
        • Transfer List
        • Upload
      • Navigation
        • Drawer
        • Link
        • Menu
        • Stepper
        • Tabs
      • Layout
        • Grid Layout
        • Grid
        • Hidden
        • Stack
      • Utilities
        • Dynamic Regions
        • Element
        • Error Boundary
        • Protect Section
        • Transitions
        • HTML
      • Surfaces
        • AppBar
        • Card
        • Paper
        • Expansion Panel
      • Custom Components
        • Building Custom JavaScript Components
    • Custom Variable Scopes
    • Interaction
    • Role Based Access
    • Scheduled Endpoints
    • Sessions
    • Static Apps
    • Themes
      • Colors
      • Cascading Style Sheets
      • Styles
  • 🌐Portal
    • About the Universal Portal
    • Portal Pages
    • Portal Widgets
      • Syntax
      • Conditions
      • Dynamic
      • Forms
      • Properties
      • Services
      • Tables
  • πŸ—οΈPlatform
    • Cache
    • Computers
    • Health Checks
    • Gallery
    • Middleware
    • Modules
    • Monitoring
    • Notifications
    • Plugins
    • Published Folders
    • Tags
    • Telemetry
    • Translations
    • User Sessions
    • Variables
  • πŸ”’Security
    • About
    • Local Accounts
    • Forms Authentication
    • Authorization
    • App Tokens
    • Enterprise Security
      • Client Certificate
      • OpenID Connect
      • SAML2
      • WS-Federation
      • Windows SSO
      • Permissions
  • βš™οΈConfiguration
    • Agent
    • App Settings
    • Best Practices
    • Branding
    • Command Line Options
    • Deployments
    • Environments
    • Feature Flags
    • Git
    • Hosting
      • Azure
      • High Availability
      • IIS
      • Reverse Proxy
    • Management API
    • Module
    • Persistence
    • psu Command Line Tool
    • Repository
    • Running as a Service Account
  • πŸ‘©β€πŸ’»Development
    • Debugging Scripts
    • Editor
    • Hangfire
    • Logging
    • Profiling
    • Visual Studio Code Extension
  • Changelogs
    • Changelog
    • Extension Changelog
    • Roadmap
    • CVEs
Powered by GitBook

PowerShell Universal

  • Downloads
  • Pricing
  • Gallery

Community

  • Issues
  • Forums
  • Discord

Support

  • Portal
  • Knowledgebase

Copyright 2025 Ironman Software

On this page
  • Enabling Plugins
  • C# API Environment
  • References
  • Namespace Using
  • Variables
  • OpenTelemetry
  • Prometheus
  • YARP

Was this helpful?

Edit on GitHub
Export as PDF
  1. Platform

Plugins

Plugins that extend the PowerShell Universal platform.

PreviousNotificationsNextPublished Folders

Last updated 5 days ago

Was this helpful?

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 for information on where to configure these options. Any changes made to the configuration will require a restart of the PowerShell Universal service.

{
    "Plugins": [
        "SQL",
        "PowerShellUniversal.Language.CSharp"
    }
}

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.

New-PSUEndpoint -Url /csharp -Path csharp.cs -Environment 'C#'

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.

public class ApiRequest
{
    public long Id { get; set; }
    public ICollection<KeyValue> Variables { get; set; } = new List<KeyValue>();
    public IEnumerable<ApiFile> Files { get; set; } = new List<ApiFile>();
    public string Url { get; set; }
    public ICollection<KeyValue> Headers { get; set; } = new List<KeyValue>();
    public byte[] Data { get; set; }
    public int ErrorAction { get; set; }
    public ICollection<KeyValue> Parameters { get; set; } = new List<KeyValue>();
    public string Method { get; set; }
    public ICollection<KeyValue> Cookies { get; set; } = new List<KeyValue>();
    public string ClaimsPrincipal { get; set; }
    public string ContentType { get; set; }
    public string[] Roles { get; set; }
}

In your endpoint, you can access this variable automatically.

if (request.ContentType == "application/json")
{
     // Do some stuff with JSON
}

The endpoint must return an ApiResponse object. This object has the following definition.

public class ApiResponse
{
    public int StatusCode { get; set; } = 200;
    public string Body { get; set; }
    public List<KeyValue> Cookies { get; set; } = new List<KeyValue>();
    public byte[] Data { get; set; } = Array.Empty<byte>();
    public string ContentType { get; set; } = "text/plain";
    public List<KeyValue> Headers { get; set; } = new List<KeyValue>();
    public ApiFile File { get; set; }
}

You can return a response by creating a new object and returning it from your endpoint.

return new ApiResponse {
    StatusCode = 401
};

When defining an endpoint's content, understand that the code is being added to a dynamically named class with a single Execute function. Your code should be valid syntax for such a source file.

using PowerShellUniversal;

public class c{id} : ExecutionClass {{ 
    public static ApiResponse Execute(ApiRequest request) 
    {{ 
        {fileContents} 

        return new ApiResponse();
    }} 
}}";

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.

var database = ServiceProvider.GetService(typeof(IDatabase));

References

You can control which assemblies are referenced by using the #ref keyword. The value can be a DLL file in the PowerShell Universal installation directory, or the full path to another assembly.

#ref PowerShellUniversal.Apis.dll
#ref C:\assemblies\markdiag.dll

Namespace Using

You can reference a namespace using the #using keyword.

#using System.Management.Automation

Variables

You can access variables in C# endpoints with GetVariable, GetSecretString, and GetSecretCredential methods.

return new ApiResponse {
    StatusCode = 200
    Body = GetVariable("MyVar").ToString()
};

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.

{    
    "OpenTelemetry": {
        "Otlp": {
            "Endpoint": "http://localhost:9090/api/v1/otlp/v1/metrics"
        }
    }
}

Prometheus

You can configure Prometheus to collect PowerShell Universal data by starting it with the OTLP collector enabled.

 .\prometheus.exe --web.enable-otlp-receiver

Within PowerShell Universal, you will need to specify the /metricsURL for the Prometheus server.

{    
    "OpenTelemetry": {
        "Otlp": {
            "Endpoint": "http://localhost:9090/metrics"
        }
    }
}

YARP

Identifier: PowerShellUniversal.Plugins.YARP

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.

{
    "ReverseProxy": {
        "Routes": {
            "route1": {
                "ClusterId": "cluster1",
                "AuthorizationPolicy": "AdministratorRolePolicy",
                "Match": {
                    "Path": "/code/{**catch-all}"
                },
                "Transforms": [
                    {
                        "PathRemovePrefix": "/code"
                    }
                ]
            }
        },
        "Clusters": {
            "cluster1": {
                "Destinations": {
                    "destination1": {
                        "Address": "http://localhost:8080"
                    }
                }
            }
        }
    }
}

You can replace the Administrator portion of the policy name to enforce a different role. For example: ExecutorRolePolicy.

The plugin enables integration with the technology. You can use to configure where to send data. PowerShell Universal currently only exposes a single OTLP endpoint configuration. The below configuration would work with Prometheus.

(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 to configure the proxy and starting the PSU service will enable the YARP functionality. Follow the to understand how to configure the service.

πŸ—οΈ
App Settings
App Settings
YARP
App Settings
YARP articles