> 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/readme/devolutions-powershell.md).

# Devolutions PowerShell

I prodotti Devolutions integrano completamente Microsoft PowerShell, offrendo potenti funzionalità di scripting e automazione. È possibile controllare i prodotti Devolutions stessi e, tramite Remote Desktop Manager, eseguire script PowerShell in tutto il suo ambiente. Detto questo, ecco come PowerShell viene utilizzato nella piattaforma Devolutions.

| Integrazione                                                                        | Scopo                                                                                                                                     | Riferimento                                                                                                                                                                                                                                                                                                                                                                                                                  |
| ----------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| Modulo Devolutions.PowerShell                                                       | Questo modulo PowerShell viene utilizzato per interagire direttamente con i prodotti Devolutions.                                         | <ul><li><a href="https://www.powershellgallery.com/packages/Devolutions.PowerShell/">PowerShell Gallery</a></li></ul>                                                                                                                                                                                                                                                                                                        |
| Azioni di Remote Desktop Manager                                                    | È possibile definire uno script PowerShell da eseguire come azione batch su uno o più host.                                               | <ul><li><a href="/pages/yc99iJJOifLOBQdZpOtX">Comandi PowerShell personalizzati</a></li><li><a href="/pages/Zwshi2QcTEWJZbfowzUs">Modifica batch con PowerShell</a></li><li><a href="/pages/Ra5c9L9Qu5289TeOClP3">Modifica dell'origine di un sincronizzatore</a></li></ul>                                                                                                                                                  |
| Report di Remote Desktop Manager                                                    | Questo tipo di voce supporta l'esecuzione di uno script PowerShell per generare un report.                                                | <ul><li><a href="/pages/J330wSM8yf2kYZJuGzye">Report PowerShell personalizzato</a></li></ul>                                                                                                                                                                                                                                                                                                                                 |
| Tipi di voce di Remote Desktop Manager                                              | Sia il tipo di voce PowerShell locale sia quello PowerShell remoto supportano l'esecuzione di script.                                     |                                                                                                                                                                                                                                                                                                                                                                                                                              |
| Provider di gestione degli accessi privilegiati (PAM) e propagazione delle password | In Devolutions Server e Devolutions Cloud, PowerShell alimenta i provider PAM personalizzati e gli script di propagazione delle password. | <ul><li><a href="https://docs.devolutions.net/pam/it/pam-with-devolutions-server/getting-started/custom-pam-providers/create-a-custom-pam-provider-in-devolutions-server">Provider PAM personalizzato di Devolutions Server</a></li><li><a href="https://docs.devolutions.net/pam/it/pam-with-devolutions-server/password-propagation-scripts">Script di propagazione delle password PAM di Devolutions Server</a></li></ul> |

### Introduzione al modulo Devolutions.PowerShell

Il modulo Devolutions.PowerShell richiede [PowerShell 7.4 o versione successiva](https://learn.microsoft.com/en-us/powershell/scripting/install/installing-powershell?view=powershell-7.4) ed è supportato sui sistemi operativi Windows, macOS e Linux.

{% hint style="warning" %}
Windows PowerShell o le versioni precedenti di PowerShell 7 non sono supportate perché il modulo è basato sullo stesso core di Remote Desktop Manager e richiede quindi una versione di PowerShell che utilizzi una versione compatibile del runtime .NET (.NET 9).
{% endhint %}

#### PowerShell Gallery (consigliato)

Il modulo Devolutions.PowerShell è disponibile in [PowerShell Gallery](https://www.powershellgallery.com/packages/Devolutions.PowerShell) ed è il metodo di installazione predefinito consigliato:

```powershell
Install-Module Devolutions.PowerShell -Force
```

Poiché PowerShell Gallery è solitamente un repository contrassegnato come non attendibile (i pacchetti non sono curati né revisionati), è necessario utilizzare `-Force` per evitare la richiesta di conferma.

#### Cloudsmith

In alternativa a PowerShell Gallery, offriamo un [repository Devolutions PowerShell](https://cloudsmith.io/~devolutions/repos/powershell/packages/) ospitato da [Cloudsmith](https://cloudsmith.com/).

1. Registri il repository Devolutions PowerShell, che può essere contrassegnato come attendibile:

   ```powershell
   Register-PSRepository -Name 'Devolutions' -SourceLocation 'https://nuget.cloudsmith.io/devolutions/powershell/v2/' -InstallationPolicy Trusted
   ```
2. Disinstalli le versioni precedenti del modulo Devolutions.PowerShell installate da PowerShell Gallery:

   ```powershell
   Uninstall-Module Devolutions.PowerShell -AllVersions
   ```
3. Installi il modulo Devolutions.PowerShell esplicitamente dal repository "Devolutions":

   ```powershell
   Install-Module Devolutions.PowerShell -Repository Devolutions
   ```
4. Confermi che il repository di origine dell'installazione del modulo Devolutions.PowerShell sia "Devolutions" e non "PSGallery":

   ```powershell
   Get-InstalledModule Devolutions.PowerShell | Select-Object -Property Name, Repository

   Name                   Repository
   ----                   ----------
   Devolutions.PowerShell Devolutions
   ```

{% hint style="info" %}
Poiché il modulo Devolutions.PowerShell è disponibile in più di un repository registrato, il parametro `-Repository` diventa obbligatorio. Tuttavia, se ha contrassegnato il repository "Devolutions" come attendibile, `-Force` non è necessario per evitare la richiesta di conferma.
{% endhint %}

#### Offline

Se deve installare il modulo Devolutions.PowerShell su un sistema con accesso a Internet limitato o assente, può farlo seguendo questi passaggi:

1. Crei un nuovo repository PowerShell chiamato "local" nella directory scelta; l'esempio seguente utilizza `C:\PSRepo`.

   ```powershell
   $RepoPath = "C:\PSRepo"
   New-Item -Path $RepoPath -ItemType 'Directory' -Force | Out-Null
   Register-PSRepository -Name 'local' -SourceLocation $RepoPath -PublishLocation $RepoPath -InstallationPolicy Trusted
   ```
2. Scarichi il file `.nupkg` per il modulo Devolutions.PowerShell utilizzando il pulsante ***Download the raw nupkg file*** sotto ***Manual Download*** in [PowerShell Gallery](https://www.powershellgallery.com/packages/Devolutions.PowerShell). Copi il file `.nupkg` nella directory del repository PowerShell locale creata in precedenza.
3. Disinstalli le versioni precedenti del modulo Devolutions.PowerShell installate da altre origini.

   ```powershell
   Uninstall-Module Devolutions.PowerShell -AllVersions
   ```
4. Installi il modulo Devolutions.PowerShell esplicitamente dal repository `local`.

   ```powershell
   Install-Module Devolutions.PowerShell -Repository local
   ```
5. Confermi che l'origine di installazione del modulo Devolutions.PowerShell sia `local`.

   ```powershell
   Get-InstalledModule Devolutions.PowerShell | Select-Object -Property Name, Repository

   Name                   Repository
   ----                   ----------
   Devolutions.PowerShell local
   ```

{% hint style="info" %}
In alternativa, è possibile utilizzare una directory su una condivisione di rete invece di una directory locale, semplificando la distribuzione del modulo PowerShell su una rete locale.
{% endhint %}

### Esempi

Per iniziare rapidamente con alcuni esempi comuni del modulo Devolutions.PowerShell, continui a leggere qui sotto.

#### Remote Desktop Manager

```powershell
# [Import module]
Import-Module Devolutions.PowerShell

# [Load workspace] Example for a local workspace (SQLite) or SQL Server
$DatasourceLocal = Get-RDMDataSource -Name "Local workspace"; Set-RDMCurrentDataSource $DatasourceLocal

$DatasourceSQL = Get-RDMDataSource -Name "SQL Server"; Set-RDMCurrentDataSource $DatasourceSQL

# [Create vault] Only the SQL Server workspace supports vaults (as do Devolutions Server and Devolutions Cloud)
$Vault = New-RDMRepository -Name 'MyVault' -Description 'My vault description' -SetRepository | Set-RDMCurrentRepository | Update-RDMUI

# [Retrieve vault]
Get-RDMRepository -Name 'MyVault'

# [Create entry] Example to create an RDP and Credential entry
$Entry = New-RDMSession -Host 'MyHost' -Type RDPConfigured -Name 'MyHost'; Set-RDMSession -Session $Entry -Refresh; Update-RDMUI

$Entry = New-RDMSession -Name 'MyCredential' -Type Credential; $Entry.Credentials.Username = 'Administrator'; Set-RDMSession $Entry -Refresh; Set-RDMSessionPassword -ID $Entry.ID -Password (ConvertTo-SecureString 'Test123$' -AsPlainText -Force)

# [Retrieve entries]
Get-RDMSession -GroupName 'MyFolder' -Name 'MyHost'

# [Update entry]
$Entry = Get-RDMSession -Name 'MyHost'; $Entry.Name = 'MyUpdatedHost'; Set-RDMSEssion $Entry | Update-RDMUI

# [Export entries]
$Entries = Get-RDMSession; $Entries | Select-Object * | Export-CSV 'C:\Export\FileName.csv' -NoTypeInformation

# [Remove entry]
Get-RDMSession -Name 'MyUpdatedHost' | Remove-RDMSession; Update-RDMUI
```

#### Devolutions Server

```powershell
# [Import module]
Import-Module Devolutions.PowerShell

# [Load workspace]
New-DSSession -Credential (Get-Credential) -BaseURI 'https://MyServer/devolutions-server/'

# [Create vault]
$Vault = New-DSVault -Name 'MyVault' -Description 'My vault description'

# [Retrieve vault]
Get-DSVault -All | Where-Object DisplayName -EQ 'MyVault'

# [Create entry]
New-DSRDPEntry -Name 'MyHost' -HostName 'MyHost' -Username 'Administrator' -Password 'Test123$' -Domain 'MyDomain' -VaultID 'VaultGUID'

New-DSCredentialEntry -Name 'MyCredential' -Username 'Administrator' -Password 'Test123$' -Domain 'MyDomain' -VaultID 'VaultGUID'

# [Retrieve entries]
Get-DSEntry -FilterBy 'Name' -FilterMatch 'StartsWith' -FilterValue 'MyHost' -SearchAllVaults

# [Update entry]
$Entry = Get-DSEntry -EntryId 'EntryGUID'; $Entry.Name = 'MyUpdatedHost'; Update-DSEntryBase -JsonBody (ConvertTo-JSON -InputObject $Entry -Depth 10)

# [Export entries]
$Entries = Get-DSEntry -SearchAllVaults; $Entries | Select-Object * | Export-CSV 'C:\Export\FileName.csv' -NoTypeInformation

# [Remove entry]
Remove-DSEntry -EntryID 'EntryGUID'
```

#### Devolutions Cloud

```powershell
# [Import module]
Import-Module Devolutions.PowerShell

# [Load workspace]
Connect-HubAccount -Url 'https://mycloud.devolutions.app' -ApplicationKey 'ApplicationKey' -ApplicationSecret 'ApplicationSecret'

# [Create vault]
$Vault = New-HubVault -VaultName 'MyVault' -VaultDescription 'My vault description'

# [Retrieve vault]
Get-HubVault

# [Create entry]
$Entry = [Devolutions.Hub.PowerShell.Entities.Hub.PSDecryptedEntry]@{
    PsMetadata = [Devolutions.Hub.PowerShell.Entities.Hub.PSEntryMetadata]@{
        Name = 'MyHost'
        ConnectionType = [Devolutions.RemoteDesktopManager.ConnectionType]::Credential
    }
    Connection = [Devolutions.RemoteDesktopManager.Business.Connection]@{
        Credentials = [Devolutions.RemoteDesktopManager.Business.CredentialsConnection]@{
            CredentialType = [Devolutions.RemoteDesktopManager.CredentialResolverConnectionType]::Default
            UserName = 'Administrator'
            Password = 'Test123$'
        }
    }
}

New-HubEntry -VaultId 'VaultGUID' -PSDecryptedEntry $Entry

# [Retrieve entries]
Get-HubEntry -VaultId 'VaultGUID' | Where-Object { $PSItem.PSMetaData.Name -EQ 'MyHost' }

# [Update entry]
$Entry = Get-HubEntry -VaultId 'VaultGUID' -EntryId 'EntryGUID'; $Entry.PsMetadata.Name = 'MyUpdatedHost'; Set-HubEntry -VaultId 'VaultGUID' -EntryId $Entry.Entry.ID.Guid -PSDecryptedEntry $Entry

# [Export entries]
$Entries = Get-HubEntry -VaultId 'VaultGUID'; $Entries | Select-Object * | Export-CSV 'C:\Export\FileName.csv' -NoTypeInformation

# [Remove entry]
Remove-HubEntry -VaultId 'VaultGUID' -EntryId 'EntryGUID'
```

### Disinstallazione del modulo Devolutions.PowerShell

Disinstalli tutte le versioni del modulo Devolutions.PowerShell:

```powershell
Uninstall-Module Devolutions.PowerShell -AllVersions
```

Se il modulo è installato tramite Cloudsmith, può annullare la registrazione del repository "Devolutions" in questo modo:

```powershell
Unregister-PSRepository Devolutions
```

Infine, se ha installato il modulo offline, può annullare la registrazione del repository "local" basato su file ed eliminare la directory associata (il nome della sua directory potrebbe essere diverso):

```powershell
Unregister-PSRepository local
Remove-Item "C:\PSRepo" -Recurse -ErrorAction SilentlyContinue
```


---

# 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/readme/devolutions-powershell.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.
