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

# Metodi di connettività PowerShell a Devolutions Server

I metodi seguenti descrivono come connettersi a Devolutions Server utilizzando PowerShell.

### Metodo 1: utilizzo dei cmdlet di Remote Desktop Manager

{% hint style="info" %}
Questo nuovo spazio di lavoro creato con PowerShell esisterà solo nel contesto utente in cui è stato creato.
{% endhint %}

1. Segua le istruzioni in [modulo Devolutions.PowerShell](/powershell/it/remote-desktop-manager-powershell/devolutions.powershell-core-module.md) per installare correttamente il modulo.
2. Crei un nuovo spazio di lavoro Devolutions Server utilizzando una [chiave applicativa e un segreto applicativo](https://docs.devolutions.net/server/it/web-interface/administration/user-and-security-management/applications-identities) con lo script seguente. Questo script dovrebbe essere utilizzato una sola volta per evitare di creare molti nuovi spazi di lavoro. Sostituisca i valori delle quattro variabili (righe da 7 a 10) con le proprie informazioni, quindi esegua lo script.

```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. Per connettersi allo spazio di lavoro, utilizzi queste righe in tutti i suoi script.

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

### Metodo 2: utilizzo dei cmdlet di Devolutions Server

1. Segua le istruzioni in [modulo Devolutions.PowerShell](/powershell/it/remote-desktop-manager-powershell/devolutions.powershell-core-module.md) per installare correttamente il modulo.
2. Lo script prevede che una [chiave applicativa e un segreto applicativo](https://docs.devolutions.net/server/it/web-interface/administration/user-and-security-management/applications-identities) e un URL siano definiti in variabili d'ambiente. Poiché memorizzare le credenziali negli script è sconsigliato, adatti un file locale per eseguire i suoi test.

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

3. Il seguente script di esempio può essere utilizzato per connettersi tramite una [chiave applicativa e un segreto applicativo](https://docs.devolutions.net/server/it/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. Una volta completato lo script e portati a termine tutti i compiti, chiuda la sessione utilizzando il cmdlet `Close-DSSession`.

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

### Vedere anche

* [Gestire le identità applicative](https://docs.devolutions.net/cloud/it/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/it/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.
