> 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/de/devolutions-server-powershell/powershell-connectivity-methods-to-devolutions-server.md).

# PowerShell-Verbindungsmethoden zu Devolutions Server

Die folgenden Methoden beschreiben, wie Sie sich mit PowerShell mit Devolutions Server verbinden.

### Methode 1: Verwendung von Remote Desktop Manager-Cmdlets

{% hint style="info" %}
Diese mit PowerShell erstellte neue Datenquelle existiert nur in dem Benutzerkontext, in dem sie erstellt wurde.
{% endhint %}

1. Befolgen Sie die Anweisungen im [Devolutions.PowerShell-Modul](/powershell/de/remote-desktop-manager-powershell/devolutions.powershell-core-module.md), um das Modul ordnungsgemäß zu installieren.
2. Erstellen Sie mit dem folgenden Skript eine neue Devolutions Server-Datenquelle unter Verwendung eines [Anwendungsschlüssels und Anwendungsgeheimnisses](https://docs.devolutions.net/server/de/web-interface/administration/user-and-security-management/applications-identities). Dieses Skript sollte nur einmal verwendet werden, um zu vermeiden, dass viele neue Datenquellen erstellt werden. Ersetzen Sie die Werte der vier Variablen (Zeilen 7 bis 10) durch Ihre eigenen Informationen und führen Sie dann das Skript aus.

```powershell
$dsname = "DVLS PowerShell"
$ds = Get-RDMDataSource -Name $dsname

# If the workspace doesn't exist, create it.
if ([string]::IsNullOrEmpty($ds))
{
  $dsname = "DVLS PowerShell"
  $dsurl = "https://your_dvls_url"
  $appkey = "your_appkey"
  $appsecret = "your_appsecret"

  $ds = New-RDMDataSource -DVLS -Name $dsname -Server $dsurl -ScriptingTenantID $appkey -ScriptingApplicationPassword $appsecret -SetDatasource -WarningAction SilentlyContinue
  Set-RDMDataSource $ds
}

Set-RDMCurrentDataSource $ds
```

3. Um sich mit der Datenquelle zu verbinden, verwenden Sie diese Zeilen in allen Ihren Skripten.

```powershell
$dsname = "DVLS PowerShell"
$ds = Get-RDMDataSource -Name $dsname
Set-RDMCurrentDataSource $ds
```

### Methode 2: Verwendung von Devolutions Server-Cmdlets

1. Befolgen Sie die Anweisungen im [Devolutions.PowerShell-Modul](/powershell/de/remote-desktop-manager-powershell/devolutions.powershell-core-module.md), um das Modul ordnungsgemäß zu installieren.
2. Das Skript erwartet, dass ein [Anwendungsschlüssel und Anwendungsgeheimnis](https://docs.devolutions.net/server/de/web-interface/administration/user-and-security-management/applications-identities) sowie eine URL in Umgebungsvariablen definiert sind. Da das Speichern von Anmeldeinformationen in Skripten verpönt ist, passen Sie eine lokale Datei für die Durchführung Ihrer eigenen Tests an.

```powershell
$env:DS_URL= "https://localhost/dvls"
$env:DS_USER = "your_appkey"
$env:DS_PASSWORD = "your_appsecret"
```

3. Das folgende Beispielskript kann verwendet werden, um sich mit einem [Anwendungsschlüssel und Anwendungsgeheimnis](https://docs.devolutions.net/server/de/web-interface/administration/user-and-security-management/applications-identities) zu verbinden.

```powershell
[string]$Username = $env:DS_USER
[string]$Password = $env:DS_PASSWORD
[string]$DVLSUrl = $env:DS_URL

[securestring]$SecPassword = ConvertTo-SecureString $Password -AsPlainText -Force
[pscredential]$Creds = New-Object System.Management.Automation.PSCredential ($Username, $SecPassword)

$Response = New-DSSession -Credential $Creds -BaseURI $DVLSUrl -AsApplication
```

4. Sobald das Skript abgeschlossen ist und alle Aufgaben erfüllt sind, schließen Sie die Sitzung mit dem Cmdlet `Close-DSSession`.

```powershell
Close-DSSession | out-null
Write-Output " "
Write-Output "...Done!"
Write-Output " "
```

### Siehe auch

* [Anwendungsidentitäten verwalten](https://docs.devolutions.net/cloud/de/web-interface/administration/management/application-identities/manage-application-identities)


---

# 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/de/devolutions-server-powershell/powershell-connectivity-methods-to-devolutions-server.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.
