> 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/da/powershell-kommandoer/new-psuvariable.md).

# New-PSUVariable

New-PSUVariable opretter en ny variabel i PowerShell Universal, der valgfrit gemmes som en hemmelighed, som en databaseværdi eller afgrænses til bestemte roller.

## Synopsis

Opretter en PowerShell Universal-variabel.

## Syntaks

```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]`.

## Beskrivelse

Opretter en variabel, der er tilgængelig for PSU-scripts. `-InputObject` uden `-Vault` serialiserer værdien som `PSObject`; i parametersættet Secret accepteres `-InputObject`, men den konverteres ikke til den gemte `-Value`. En `PSCredential`, der angives via `-Value`, gemmer brugernavn og adgangskode med typen `PSCredential`. Eksisterende variabelnavne (uanset store og små bogstaver) afvises, medmindre `-Force` angives. `-Required` markerer en variabel som påkrævet, hvilket kan bruges af miljøets modulkrav, så et modul ikke betragtes som klart, før variablen er tilgængelig.

## Eksempel

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

## Parametre

| Parameter                | Beskrivelse                                                                           |
| ------------------------ | ------------------------------------------------------------------------------------- |
| `-Name`                  | Påkrævet entydigt variabelnavn.                                                       |
| `-Value`                 | Værdi, der skal gemmes; strengværdier kan deserialiseres fra CLIXML.                  |
| `-InputObject`           | Objekt serialiseret som `PSObject` kun i parametersættet InputObject (uden `-Vault`). |
| `-Vault`                 | Navn på hemmelighedsboksen for parametersættet Secret.                                |
| `-Type`                  | Variabeltype, standard `System.String`, hvor ingen værdi tilsidesætter den.           |
| `-Description`           | Beskrivelse af variablen.                                                             |
| `-DisableRunAsSupport`   | Deaktiverer brug som Run As-legitimationsoplysning.                                   |
| `-Database`              | Gemmer værdien i databasen.                                                           |
| `-Required`              | Markerer variablen som påkrævet.                                                      |
| `-Role`                  | Roller med tilladelse til at få adgang til variablen.                                 |
| `-Force`                 | Tillader oprettelse, når navnet allerede findes.                                      |
| `-Scope`                 | Variabelomfang.                                                                       |
| `-Tag`                   | Mærker til variablen.                                                                 |
| `-PasswordNotRequired`   | Markerer adgangskoden for en legitimationsoplysning som ikke påkrævet.                |
| `-ComputerName`          | URL eller værtsnavn for PSU-målserveren (alias `-Uri`).                               |
| `-AppToken`              | App-token til Management API.                                                         |
| `-Credential`            | Legitimationsoplysninger til Management API.                                          |
| `-UseDefaultCredentials` | Bruger de aktuelle Windows-legitimationsoplysninger.                                  |
| `-Integrated`            | Bruger den integrerede administrationsklient i processen.                             |
| `-TrustCertificate`      | Ignorerer fejl ved certifikatvalidering.                                              |
| `-Cookies`               | Genbruger sessionscookies til godkendelse.                                            |

## Tilladelser

Adgangstokenet kræver `platform.variables/create` for at køre denne cmdlet eksternt.


---

# 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/da/powershell-kommandoer/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.
