> 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/apps/components/inputs/switch.md).

# Switch

Fügen Sie PowerShell Universal-Apps Umschalter hinzu, um Einstellungen ein- oder auszuschalten, mit Änderungs-Event-Handlern und Wertabruf über Get-UDElement.

Switches schalten den Zustand einer einzelnen Einstellung ein oder aus.

Switches sind die bevorzugte Möglichkeit, Einstellungen auf Mobilgeräten anzupassen. Die Option, die der Switch steuert, sowie der Zustand, in dem er sich befindet, sollten aus der zugehörigen Inline-Beschriftung klar hervorgehen.

## Switch

Erstellen Sie einen einfachen Switch.

```powershell
New-UDSwitch -Checked $true 
New-UDSwitch -Checked $true -Disabled
```

## OnChange-Event

Reagieren Sie darauf, wenn ein Switch-Wert geändert wird. Die Variable `$EventData` enthält, ob der Switch aktiviert oder deaktiviert wurde.

```powershell
New-UDSwitch -OnChange { Show-UDToast -Message $EventData }
```

## Get-UDElement-Unterstützung

Sie können den Wert des Switches innerhalb einer anderen Komponente mit `Get-UDElement` abrufen. Verwenden Sie die Eigenschaft Checked, um zu bestimmen, ob der Switch aktiviert ist oder nicht.

```powershell
New-UDSwitch -Id 'switch' 
New-UDButton -Text 'Click' -OnClick {
    Show-UDToast -Message (Get-UDElement -Id 'switch').checked
}
```

## API

* [New-UDSwitch](/powershell-universal/de/powershell-befehle/new-udswitch.md)

### Siehe auch

* [Devolutions Academy – Adding user unlock feature](https://academy.devolutions.net/student/activity/3546024-part-4-adding-user-unlock-feature)


---

# 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/de/apps/components/inputs/switch.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.
