Settings

Describes how to set application settings and a definition of the settings.

Application settings can be found within the appsettings.json file within the installation directory. This file defines various settings you can apply to Universal. Although you can edit this file directly, it's recommended that you use one of the following methods to persist settings as the appsettings.json file in the installation directory will be overridden on upgrades.

When installed from the MSI, the installation directory for PowerShell Universal is ${env:ProgramFiles(x86)}\Universal.

ProgramData AppSettings.json

You can create an appsettings.json file within the $Env:ProgramData\PowerShellUniversal folder. You can use a subset of the settings from within the appsettings.json file. For example, if you wanted to override the JWT settings, you could have an appsettings.json file like this.

{
  "Jwt": {  
    "SigningKey": "PleaseUseYourOwnSigningKeyHere",  
    "Issuer": "IronmanSoftware",
    "Audience": "PowerShellUniversal"
  }
}

Environment Variables

You can also set environment variables for your settings. Environment variables should have an underscore between each subset of the appsettings.json file. For example, if you want to change the JWT signing key via environment variable, you would set the variable $Env:Jwt__SigningKey. If you wanted to set the external API URL, you would set $Env:Api__Url.

Examples

Using an environment variable for the OpenID Connect secret.

$Env:Authentication__OIDC__ClientSecret = "mySecret"

Using an environment variable for JWT signing key.

$Env:Jwt__SigningKey = "mySigningKey"

Command Line

PowerShell Universal 2.6 or later

You can specify the location of the appsettings.json file by using the --appsettings command line argument for Universal.Server.exe .

.\Universal.Server.exe --appsettings C:\appsettings.json

Setting Descriptions

Kestrel / Endpoints

Default Value

    "Kestrel": {
  "Endpoints": {
    "HTTP": {
      "Url": "http://*:5000"
    }
  },
  "RedirectToHttps": "false"
},

The Kestrel endpoints section allows you to configure the web server. This settings are not used when hosting in IIS. In this section you can configure options like HTTPS and the port that Universal is listening on.

Kestrel is the web server implementation for ASP.NET Core that PowerShell Universal uses. For more information on the configuration options for Kestrel, visit this Microsoft Documentation page.

Application Insights

Default value

    "ApplicationInsights": {
  "InstrumentationKey": ""
},

Logging

Default Value

    "Logging": {
  "Path": "%PROGRAMDATA%/PowerShellUniversal/log.txt",
  "RetainedFileCountLimit": 31,
  "LogLevel": {
    "Default": "Information",
    "Microsoft": "Warning",
    "Microsoft.Hosting.Lifetime": "Information"
  }
},

The logging options define the level of logging exposed by Universal. The core Universal logging setting Logging / LogLevel / Default can be adjusted to increase the level of logging by the Universal components.

AllowedHosts

Default Value

    "AllowedHosts": "*",

The hosts that are allowed to connect to the webserver. Defaults to any host.

CorsHosts

Default Value

    "CorsHosts": "",

Configures the hosts that are allowed to make cross-origin resource sharing requests (CORS) to the server. To allow multiple hosts, separate each host by a semicolon.

"CorsHosts" : "https://www.google.com;https://login.microsoftonline.com"

Data

Default Value

    "Data": {
  "RepositoryPath": "%ProgramData%\\UniversalAutomation\\Repository",
  "ConnectionString": "%ProgramData%\\UniversalAutomation\\database.db",
  "GitRemote": "",
  "GitUserName": "",
  "GitPassword": "", 
  "GitBranch": "",
  "ConfigurationScript": ""
},

API

Default Value

    "Api": {
  "Url": ""
},

Authentication

Default Value

    "Authentication" : {
    "Windows": {
      "Enabled": "false"
    },
    "WSFed": {
      "Enabled": "false",
      "MetadataAddress": "",
      "Wtrealm": "",
      "CallbackPath": "/auth/signin-wsfed",
      "Wreply": "",
      "UseTokenLifetime": true,
      "CorrelationCookieSameSite": ""
    },
    "OIDC": {
      "Enabled": "false",
      "CallbackPath": "/auth/signin-oidc",
      "ClientID": "",
      "ClientSecret": "",
      "Resource": "",
      "Authority": "",
      "ResponseType": "",
      "SaveTokens": "false",
      "CorrelationCookieSameSite": "",
      "UseTokenLifetime": true
    },
    "SessionTimeout": "25"
  },

Windows

OIDC

OpenID Connect authentication settings.

WSFed

WS-Federation authentication settings.

JWT

JSON Web Token configuration settings

Default Value

    "Jwt": {  
  "SigningKey": "PleaseUseYourOwnSigningKeyHere",  
  "Issuer": "IronmanSoftware",
  "Audience": "PowerShellUniversal"
},

UniversalDashboard

Default Value

    "UniversalDashboard": {
  "AssetsFolder": "%ProgramData%\\PowerShellUniversal\\Dashboard"
},

HideAdminConsole

Prevents the service from serving the admin console. This will prevent the admin console from being used by any user, including administrators.

Last updated

Copyright 2024 Ironman Software