> 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/de/powershell-befehle/new-udform.md).

# New-UDForm

New-UDForm erstellt ein PowerShell Universal-Formular mit Eingabesteuerelementen, die ihre Werte melden, wenn auf die Schaltfläche zum Absenden geklickt wird.

### Synopsis

Formulare können eine beliebige Anzahl von Eingabesteuerelementen enthalten. Jedes dieser Steuerelemente meldet seinen Wert an das Formular, wenn auf die Schaltfläche zum Absenden geklickt wird.

### Syntax

```powershell
New-UDForm [-Id <String>] [-OnValidate <Endpoint>] [-SubmitText <String>] [-CancelText <String>] [-ButtonVariant <String>] [-ClassName <String>] [-DisableSubmitOnEnter] [-Script <String>] [-OutputType <String>] [-ShowBackButton] [<CommonParameters>]

New-UDForm [-Id <String>] -Children <ScriptBlock> -OnSubmit <Endpoint> [-OnValidate <Endpoint>] [-OnProcessing <ScriptBlock>] [-OnCancel <Endpoint>] [-SubmitText <String>] [-CancelText <String>] [-ButtonVariant <String>] [-ClassName <String>] [-DisableSubmitOnEnter] [<CommonParameters>]

New-UDForm [-Id <String>] -OnSubmit <Endpoint> [-ButtonVariant <String>] [-ClassName <String>] -Schema <Hashtable> [-UiSchema <Hashtable>] [-FormData <Hashtable>] [-DisableSubmitOnEnter] [<CommonParameters>]
```

### Beschreibung

Erstellt ein neues Formular. Formulare können eine beliebige Anzahl von Eingabesteuerelementen enthalten. Jedes dieser Steuerelemente meldet seinen Wert an das Formular, wenn auf die Schaltfläche zum Absenden geklickt wird.

### Parameter

#### -Id

Die ID der Komponente. Standardmäßig eine zufällige GUID.

```
Required?                    false
Position?                    named
Default value                [Guid]::NewGuid().ToString()
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Children

Steuerelemente, aus denen dieses Formular besteht. Dies kann eine beliebige Kombination von Steuerelementen sein. Eingabesteuerelemente melden ihren Zustand an das Formular.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnSubmit

Ein Skriptblock, der beim Absenden des Formulars ausgeführt wird. Sie können Steuerelemente aus diesem Skriptblock zurückgeben, und das Formular wird durch den Skriptblock ersetzt. Die Variable $EventData enthält eine Hashtable aller Eingabefelder und ihrer Werte.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnValidate

Ein Skriptblock, der das Formular validiert. Gibt das Ergebnis eines Aufrufs von New-UDFormValidationResult zurück.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnProcessing

Ein Skriptblock, der aufgerufen wird, wenn das Formular mit der Verarbeitung beginnt. Der Rückgabewert dieses Skriptblocks sollte eine Komponente sein, die einen Ladedialog anzeigt. Der Skriptblock erhält die aktuellen Formulardaten.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OnCancel

Ein Skriptblock, der aufgerufen wird, wenn ein Formular abgebrochen wird. Nützlich zum Schließen von Formularen in modalen Fenstern.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -SubmitText

Text, der in der Schaltfläche zum Absenden angezeigt wird. Standardmäßig 'Submit'.

```
Required?                    false
Position?                    named
Default value                Submit
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -CancelText

Text, der in der Schaltfläche zum Abbrechen angezeigt wird. Standardmäßig 'Cancel'.

```
Required?                    false
Position?                    named
Default value                Cancel
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ButtonVariant

Art der anzuzeigenden Schaltfläche. Standardmäßig text. Gültige Werte sind contained, outlined, text.

```
Required?                    false
Position?                    named
Default value                text
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ClassName

Eine CSS-Klasse, die auf das Formular angewendet wird.

```
Required?                    false
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Schema

Definiert ein Formular auf Basis einer Hashtable mit einem Schema. Diese Version von Formularen basiert auf react-jsonschema-form.

```
Required?                    true
Position?                    named
Default value
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -UiSchema

Wird verwendet, um die Reihenfolge der Felder zu ändern (siehe Dokumentation)

```
Required?                    false
Position?                    named
Default value                @{}
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -FormData

```
Required?                    false
Position?                    named
Default value                @{}
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -DisableSubmitOnEnter

Deaktiviert die Funktion, bei der das Drücken der Eingabetaste in einem Textfeld das zugehörige Formular absendet.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -Script

Wird verwendet, um automatisch Formulare auf Basis von Skripten in Ihrer PowerShell Universal-Umgebung zu generieren. Skriptformulare generieren Eingabekomponenten auf Basis des param-Blocks. Skriptformulare unterstützen automatisch Fortschritt und Rückmeldungen.

```
Required?                    false
Position?                    named
Default value                None
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -OutputType

Der Typ der Ausgabe, die vom Skript zurückgegeben wird. Gültige Werte sind: "Text", "Table"

```
Required?                    false
Position?                    named
Default value                Text
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### -ShowBackButton

Zeigt nach dem Absenden des Formulars eine Schaltfläche „Zurück“ an. Dies wird nur für Skriptformulare verwendet.

```
Required?                    false
Position?                    named
Default value                False
Accept pipeline input?       false
Aliases
Accept wildcard characters?  false
```

#### Allgemeine Parameter

Dieses Cmdlet unterstützt die allgemeinen Parameter: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer, PipelineVariable und OutVariable. Weitere Informationen finden Sie unter [about\_CommonParameters](https://go.microsoft.com/fwlink/?LinkID=113216).

### Ausgaben

### Beispiele

#### Beispiel 1: Grundlagen

```powershell
New-UDForm -Id 'form1' -Content {
    New-UDTextbox -Id 'form1Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form1Textbox)
}
```

Erstellt ein einfaches Formular.

#### Beispiel 2: Validierung

```powershell
New-UDForm -Id 'form2' -Content {
    New-UDTextbox -Id 'form2Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form2Textbox)
} -OnValidate {
    if ($EventData.form2Textbox -eq 'Bob') {
        New-UDValidationResult -ValidationError 'Bob is not allowed'
    }
    else {
        New-UDValidationResult -Valid
    }
}
```

Erstellt ein Formular mit Validierung.

#### Beispiel 3: Verarbeitung

```powershell
New-UDForm -Id 'form3' -Content {
    New-UDTextbox -Id 'form3Textbox' -Label 'Name'
} -OnSubmit {
    Start-Sleep -Seconds 5
    Show-UDToast -Message ($EventData.form3Textbox)
} -OnProcessing {
    New-UDCard -Title 'Processing' -Content {
        New-UDProgress
    }
}
```

Erstellt ein Formular mit einem Verarbeitungsdialog.

#### Beispiel 4: Abbrechen

```powershell
New-UDForm -Id 'form4' -Content {
    New-UDTextbox -Id 'form4Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form4Textbox)
} -OnCancel {
    Show-UDToast -Message 'Form was cancelled'
}
```

Erstellt ein Formular mit einer Schaltfläche zum Abbrechen.

#### Beispiel 5: Text für Absenden und Abbrechen

```powershell
New-UDForm -Id 'form5' -Content {
    New-UDTextbox -Id 'form5Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form5Textbox)
} -SubmitText 'Save' -CancelText 'Close' -OnCancel {
    Show-UDToast -Message 'Form was cancelled'
}
```

Erstellt ein Formular mit benutzerdefiniertem Text für Absenden und Abbrechen.

#### Beispiel 6: Schaltflächenvariante

```powershell
New-UDForm -Id 'form6' -Content {
    New-UDTextbox -Id 'form6Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form6Textbox)
} -ButtonVariant 'contained'
```

Erstellt ein Formular mit der Schaltflächenvariante contained.

#### Beispiel 7: Klassenname

```powershell
New-UDForm -Id 'form7' -Content {
    New-UDTextbox -Id 'form7Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form7Textbox)
} -ClassName 'my-form'
```

Erstellt ein Formular mit einem benutzerdefinierten CSS-Klassennamen.

#### Beispiel 8: Schema

```powershell
New-UDForm -Id 'form8' -Schema @{
    title = "Test Form"
    type = "object"
    properties = @{
       name = @{
           type = "string"
       }
       age = @{
           type = "number"
       }
    }
} -OnSubmit {
    Show-UDToast -Message ($EventData.name)
    Show-UDToast -Message ($EventData.age)
}
```

Erstellt ein Formular mit einem Schema. Weitere Informationen zu JSON Schema finden Sie hier: <https://rjsf-team.github.io/react-jsonschema-form/docs/>

#### Beispiel 9: UI-Schema

```powershell
New-UDForm -Id 'form9' -Schema @{
    title = "Test Form"
    type = "object"
    properties = @{
       name = @{
           type = "string"
       }
       age = @{
           type = "number"
       }
    }
} -uiSchema @{
	"ui:order" = @('age','name')
} -FormData @{ Name = "adam"; Age = 38 } -OnSubmit {
    Show-UDToast -Message ($EventData.name)
}
```

Erstellt ein Formular mit einem Schema und einem UI-Schema. Weitere Informationen zu JSON Schema finden Sie hier: <https://rjsf-team.github.io/react-jsonschema-form/docs/>

#### Beispiel 10: Skript

```powershell
New-UDForm -Id 'form10' -Script "Script1.ps1" -OutputType "Table"
```

Erstellt ein Formular aus einem Skript. Die Parameter des Skripts definieren das Formular. Die Ausgabe des Skripts wird in einer Tabelle angezeigt.

#### Beispiel 11

```powershell
New-UDForm -Id 'form11' -Content {
   New-UDTextbox -Id 'form11Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form11Textbox)
}
New-UDButton -Text "A submit button outside the form" -OnClick {
    Invoke-UDForm -Id "form11"
}

Invoke-UDForm|Creates a form with a submit button outside the form.
```

#### Beispiel 12

```powershell
New-UDForm -Id 'form12' -Content {
   New-UDTextbox -Id 'form12Textbox' -Label 'Name'
} -OnSubmit {
    Show-UDToast -Message ($EventData.form12Textbox)
} -OnValidate {
    if ($EventData.form12Textbox -eq 'Hello') {
        New-UDValidationResult -Valid
    }
    else {
        New-UDValidationResult -ValidationError "Name must be 'Hello'"
    }
}
New-UDButton -Text "Validate form" -OnClick {
    Test-UDForm -Id "form12"
}

Test-UDForm|Creates a form with a validate button outside the form.
```


---

# 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 dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.devolutions.net/powershell-universal/de/powershell-befehle/new-udform.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
