Information about execution environments.
Environments allow you to define an executable, arguments, modules and variables to use when running scripts, hosting APIs and dashboards.
Environments are stored within the
To configure environments, you can use the Settings \ Environments page.
Environments support setting the name, path, arguments, modules and variables.
The name of the environment. This name will be shown through out the rest of the platform when running scripts, configuring the API host environment and hosting dashboards.
Environments support defining a path to an executable and arguments for that executable. These should be either PowerShell.exe or Pwsh.exe.
You can also define modules and variables.
The modules list allows you to define zero or more modules to load in the PowerShell runspaces for the environment. These modules will be part of the initial session state so they will not need to be loaded manually. Items added to this list can either be module names or full paths to module files.
The variables list allows you to define zero or more variables to load in the PowerShell runspaces for the environment. This list can consist of variable names from the variable configuration.
You can also use wild cards (
*) to bring in multiple variables that match a pattern.
You can use the
New-PSUEnvironmentto configure additional PSModulePaths to include within the environment.
Available in PowerShell Universal 2.8 or later.
New-PSUEnvironmentwill cause runspaces to be disposed and recreated periodically. This may increase CPU usage but reduce memory usage in some environments.
Available in PowerShell Universal 2.9 or later.
High Performance Runspace Pools uses an alternate technique to pooling resources. They are much faster than pools traditionally used by PowerShell Universal. APIs and Dashboards support the use of these types of pools.
High performance pools do not support debugging, persistence or runspace recycling.
Environments can be used across the platform.
To select the environment to use, modify the
settings.ps1file and include the
Set-PSUSetting. It needs to be the name of the environment.
Each script, job and schedule can use an environment. You can define environments for scripts by modifying the
scripts.ps1and setting the
New-PSUScript. To set the environment of a schedule, set the
schedules.ps1. When invoking a script, you can also choose an environment to use.
To use a particular environment for a dashboard, set the
By default, authentication and authorization happen within the
Universal.Server.exeprocess. To run these out of process, you can select an environment by setting the
The integrated environment does not support running as alternate credentials.
The integrated environment uses the PowerShell Universal server process directly rather than starting external PowerShell processes to service requests.
The integrated environment is easier to configure and use than having multiple disparate environments. You will also see a performance improvement because there is no need to serialize and communicate via interprocess communication.
The downside is that you cannot elevate to alternate credentials or use alternate PowerShell versions. You will be using the current version of the PowerShell Universal server's PowerShell SDK.
The integrated environment is always available and you do not need to configured it directly. If you do want to import modules or set up persistent runspaces, you can set settings for the integrated environment in
New-PSUEnvironment -Name 'Integrated' -Path 'none' -Modules @('ActiveDirectory')
To set the integrated environment, you can use the
Set-PSUSetting -ApiEnvironment 'Integrated'
You can assign the integrated environment to scripts and schedules. You can also set the integrated environment as the default environment for the platform.
Set-PSetting -DefaultEnvironment 'Integrated'
You can also choose the integrated environment from the run dialog.
You can run dashboards in the integrated environment. Select the integrated environment from the environment drop down.
The integrated environment works by creating multiple ruspaces within the PowerShell Universal service. Some modules do not work well when run within a single process. Below is a list of modules with known issues running within the integrated environment.