> For the complete documentation index, see [llms.txt](https://docs.devolutions.net/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuenvironment.md).

# New-PSUEnvironment

New-PSUEnvironment creates a PowerShell execution environment in PowerShell Universal, defining the runspace, modules, and startup script.

## SYNOPSIS

Creates a PowerShell Universal execution environment.

## SYNTAX

```powershell
New-PSUEnvironment -Name <String> [-Version <String>] [-Type <EnvironmentType>] [-Path <String>] [-Arguments <String>] [-Modules <String[]>] [-Variables <String[]>] [-PSModulePath <String[]>] [-StartupScript <String[]>] [-PersistentRunspace] [-RunspaceRecycling] [-MaxRunspaces <Int32>] [-MaxVirtualMemory <Int64>] [-RunspaceSaturationWarningThresholdPercent <Int32>] [-RunspaceSaturationWarningDurationSeconds <Int32>] [-RecycleSchedule <String>] [-Credential <Variable>] [-Description <String>] [-DisableImplicitWinCompat] [-Minimal] [-Disabled] [-ProcessStartupScript <String>] [-EnableDebugger] [-Verb <String>] [-PowerShellVersion <String>] [-Virtual] [-ContainerImageUrl <String>] [-ContainerImageTag <String>] [-ContainerPull] [<ConnectionOptions>] [<CommonParameters>]
```

`<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`. `-Credential` here is a PSU credential variable for execution, not a Management API credential.

## DESCRIPTION

Creates an environment for APIs, scripts, apps, and security processes. `-Type` accepts `Custom`, `WindowsPowerShell`, `PowerShell7`, `Isolated`, or `Container`. For `Isolated`, `-PowerShellVersion` accepts an installed version or a multi-pwsh selector such as `stable`, `preview`, `lts`, or `7.4`; `-Virtual` enables a managed multi-pwsh virtual environment. Container options configure the image URL, tag, and whether to pull it. `-EnableDebugger` is retained for compatibility but is no longer required and emits a warning.

## EXAMPLE

```powershell
New-PSUEnvironment -Name 'Isolated 7.4' -Type Isolated -PowerShellVersion '7.4' -Virtual
```

## PARAMETERS

| Parameter                                    | Description                                                                                 |
| -------------------------------------------- | ------------------------------------------------------------------------------------------- |
| `-Name`                                      | Required environment name.                                                                  |
| `-Version`                                   | Environment version identifier; defaults to its name.                                       |
| `-Type`                                      | Environment type: `Custom`, `WindowsPowerShell`, `PowerShell7`, `Isolated`, or `Container`. |
| `-Path`                                      | Executable path for the environment.                                                        |
| `-Arguments`                                 | Additional process arguments.                                                               |
| `-Modules`                                   | Modules configured for the environment.                                                     |
| `-Variables`                                 | PSU variable names available to the environment; defaults to `*`.                           |
| `-PSModulePath`                              | Additional PowerShell module paths.                                                         |
| `-StartupScript`                             | Scripts to execute when runspaces start.                                                    |
| `-PersistentRunspace`                        | Enables a persistent runspace.                                                              |
| `-RunspaceRecycling`                         | Enables runspace recycling.                                                                 |
| `-MaxRunspaces`                              | Maximum runspaces (default 25).                                                             |
| `-MaxVirtualMemory`                          | Maximum virtual memory in MB; converted to bytes for storage.                               |
| `-RunspaceSaturationWarningThresholdPercent` | Runspace saturation warning threshold percent (default 80).                                 |
| `-RunspaceSaturationWarningDurationSeconds`  | Saturation warning duration in seconds (default 30).                                        |
| `-RecycleSchedule`                           | Schedule for recycling runspaces.                                                           |
| `-Credential`                                | PSU credential variable for execution, not a Management API `PSCredential`.                 |
| `-Description`                               | Environment description.                                                                    |
| `-DisableImplicitWinCompat`                  | Disables implicit Windows compatibility.                                                    |
| `-Minimal`                                   | Enables minimal environment startup.                                                        |
| `-Disabled`                                  | Creates the environment disabled.                                                           |
| `-ProcessStartupScript`                      | Script run at process startup.                                                              |
| `-EnableDebugger`                            | Legacy compatibility switch; now only emits a warning.                                      |
| `-Verb`                                      | Verb used to launch the executable.                                                         |
| `-PowerShellVersion`                         | Installed PowerShell version or multi-pwsh selector for isolated environments.              |
| `-Virtual`                                   | Enables a managed virtual environment.                                                      |
| `-ContainerImageUrl`                         | Container image URL.                                                                        |
| `-ContainerImageTag`                         | Container image tag.                                                                        |
| `-ContainerPull`                             | Pulls the configured container image.                                                       |
| `-ComputerName`                              | Target PSU server URL or host name (alias `-Uri`).                                          |
| `-AppToken`                                  | Management API app token.                                                                   |
| `-UseDefaultCredentials`                     | Uses current Windows credentials.                                                           |
| `-Integrated`                                | Uses the in-process management client.                                                      |
| `-TrustCertificate`                          | Ignores certificate validation errors.                                                      |
| `-Cookies`                                   | Reuses session authentication cookies.                                                      |

## PERMISSIONS

The access token requires `settings.environments/create` to run this cmdlet remotely.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.devolutions.net/powershell-universal/powershell-commands/new-psuenvironment.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
