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

# PowerShell connectivity methods to Devolutions Server

Opret forbindelse til Devolutions Server med PowerShell ved hjælp af Remote Desktop Manager cmdlets eller Devolutions Server cmdlets og program nøgle godkendelse.

Følgende metoder describe hvordan at opretter forbindelse til Devolutions Server ved hjælp af PowerShell.

### Metode 1: Ved hjælp af Remote Desktop Manager Cmdlets

{% hint style="info" %}
Denne ny arbejdsområde oprettet med PowerShell vil kun exist i brugeren kontekst den var oprettet.
{% endhint %}

1. Follow instruktioner i [Devolutions.PowerShell modul](/powershell/da/remote-desktop-manager-powershell/devolutions.powershell-core-module.md) til korrekt install modulet.
2. Opret en ny Devolutions Server arbejdsområde ved hjælp af en [Program Nøgle og Program Hemmelighed](https://docs.devolutions.net/server/web-interface/administration/user-and-security-management/applications-identities) med følgende script. Denne script bør kun være brugt én gang til avoid creating mange ny arbejdsområder. Replace værdierne af four variabler (linjer 7 til 10) med Deres egen oplysning, derefter run scriptet.

```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. For at opretter forbindelse til arbejdsområdet, brug disse linjer i alle Deres scripts.

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

### Metode 2: Ved hjælp af Devolutions Server Cmdlets

1. Follow instruktioner i [Devolutions.PowerShell modul](/powershell/da/remote-desktop-manager-powershell/devolutions.powershell-core-module.md) til korrekt install modulet.
2. Scriptet expects en [Program Nøgle og Program Hemmelighed](https://docs.devolutions.net/server/web-interface/administration/user-and-security-management/applications-identities) og URL til være defineret i miljø variabler. Since storing legitimationsoplysninger i scripts er frowned upon, adapt en lokal fil for kørende Deres egen tester.

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

3. Følgende eksempel script kan være brugt at opretter forbindelse ved hjælp af en [Program Nøgle og Program Hemmelighed](https://docs.devolutions.net/server/web-interface/administration/user-and-security-management/applications-identities).

```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. Én gang scriptet er fuldført og alle opgaver er fulfilled, close sessionen ved hjælp af `Close-DSSession` cmdlet.

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

### Se også

* [Manage application identities](https://docs.devolutions.net/cloud/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 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/da/devolutions-server-powershell/powershell-connectivity-methods-to-devolutions-server.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.
