> 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-psuvariable.md).

# New-PSUVariable

New-PSUVariable creates a new variable in PowerShell Universal, optionally stored as a secret, database value, or scoped to specific roles.

## SYNOPSIS

Creates a PowerShell Universal variable.

## SYNTAX

```powershell
New-PSUVariable -Name <String> [-Value <Object>] [<VariableOptions>] [<ConnectionOptions>]
New-PSUVariable -Name <String> [-InputObject <Object>] [<VariableOptions>] [<ConnectionOptions>]
New-PSUVariable -Name <String> -Vault <String> [-Value <Object>] [-InputObject <Object>] [<VariableOptions>] [<ConnectionOptions>]
```

`<VariableOptions>`: `[-Type <String>] [-Description <String>] [-DisableRunAsSupport] [-Database] [-Required] [-Role <String[]>] [-Force] [-Scope <VariableScope>] [-Tag <Tag[]>] [-PasswordNotRequired]`. `<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`.

## DESCRIPTION

Creates a variable available to PSU scripts. `-InputObject` without `-Vault` serializes its value as `PSObject`; in the Secret parameter set `-InputObject` is accepted but is not converted into the stored `-Value`. A `PSCredential` supplied through `-Value` stores its username and password with type `PSCredential`. Existing variable names (case-insensitive) are rejected unless `-Force` is supplied. `-Required` marks a variable as required, which can be used by environment module requirements so a module is not considered ready until the variable is available.

## EXAMPLE

```powershell
New-PSUVariable -Name 'ApiKey' -Required -Description 'API key required by the integration'
```

## PARAMETERS

| Parameter                | Description                                                                               |
| ------------------------ | ----------------------------------------------------------------------------------------- |
| `-Name`                  | Required unique variable name.                                                            |
| `-Value`                 | Value to store; string values may be deserialized from CLIXML.                            |
| `-InputObject`           | Object serialized as `PSObject` only in the InputObject parameter set (without `-Vault`). |
| `-Vault`                 | Name of the secret vault for the Secret parameter set.                                    |
| `-Type`                  | Variable type, default `System.String` where no value overrides it.                       |
| `-Description`           | Variable description.                                                                     |
| `-DisableRunAsSupport`   | Disables use as a Run As credential.                                                      |
| `-Database`              | Stores the value in the database.                                                         |
| `-Required`              | Marks the variable as required.                                                           |
| `-Role`                  | Roles allowed to access the variable.                                                     |
| `-Force`                 | Allows creation when the name already exists.                                             |
| `-Scope`                 | Variable scope.                                                                           |
| `-Tag`                   | Tags for the variable.                                                                    |
| `-PasswordNotRequired`   | Marks a credential's password as not required.                                            |
| `-ComputerName`          | Target PSU server URL or host name (alias `-Uri`).                                        |
| `-AppToken`              | Management API app token.                                                                 |
| `-Credential`            | Management API credentials.                                                               |
| `-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 `platform.variables/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-psuvariable.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.
