> 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/rdm/it/knowledge-base/knowledge-base-articles/entry-settings/custom-powershell-synchronizer.md).

# Sincronizzatore personalizzato (PowerShell)

Questa voce è un potente sincronizzatore "ibrido" che le consente di utilizzare script PowerShell per popolare le casseforti, sincronizzare le descrizioni, applicare modelli e altro ancora. Può sincronizzare da origini per le quali non disponiamo di un sincronizzatore dedicato. Sfrutta le classi proxy per interagire con i ricchi oggetti di connessione di Remote Desktop Manager.

{% hint style="info" %}
Consulti [PowerShell commands](https://docs.devolutions.net/powershell/it/powershell-commands) per un elenco dei comandi PS personalizzati di Devolutions, completo di descrizioni, esempi e parametri comuni supportati.
{% endhint %}

### Casi d'uso del sincronizzatore Custom (PowerShell)

#### Sessione semplice

Fornisca l'host, il nome, la descrizione e il gruppo utilizzando il tipo RDP predefinito. In alternativa, utilizzi un modello per favorire il riutilizzo e la standardizzazione. Ecco un esempio:

```powershell
# Obtain or generate your list of sessions to create, here we assume a $data table.
# Has been filled by querying an external source.
Foreach($row in $data)
{
  # Create a new session, the only mandatory property is 'Name' so we require it as a parameter in the Add method.
  $session = $RDM.Add($row.Name)
  # Set the other properties using $session.
  $session.Host = $row.Name
  $session.Description = $row.Description
  $session.Group = $row.Group # it can be multiple levels i.e. 'Folder1\Folder1a'
}
```

#### Sessione con credenziali

Per impostare le credenziali, utilizzi: `$session.SetCredentials($row.Username, $row.Password, $row.Domain);`.

Per impostare solo la password, utilizzi: `$session.SetPassword($row.Password);`.

{% hint style="info" %}
La password non può essere impostata utilizzando `$session.Password`.
{% endhint %}

#### Campi di uso comune

Ecco i campi di uso comune per una rapida consultazione:

```
string CustomStatus
string Description
bool Encrypt
string Group
string Host
bool IncludeInFavorite
string Name
bool OpenEmbedded
bool ShowInTrayIcon
int SortPriority
<Color>#FF0000</Color>
string GroupTab
string Status
string TabTitle
```

#### Scenario avanzato

Utilizzando il metodo descritto in [Reverse engineering an entry's structure](https://docs.devolutions.net/powershell/it/remote-desktop-manager-powershell/powershell-scripting/list-of-property-names-for-powershell-script#reverse-engineering-an-entrys-structure), può creare una voce con tutte le informazioni necessarie nei campi appropriati e osservare come assegnare i valori tramite PowerShell.\
\
Ad esempio, ecco una voce ***Host*** per la quale sono stati compilati molti campi della sezione ***View*** – ***Asset***:

```xml
<?xml version="1.0" encoding="utf-8"?>
<ArrayOfConnection>
  <Connection>
    <AppVersion>~SET AUTOMATICALLY~</AppVersion>
    <Color>#FF0000</Color>
    <ConnectionType>Host</ConnectionType>
    <CreatedBy>~SET AUTOMATICALLY~</CreatedBy>
    <CreationDateTime>~SET AUTOMATICALLY~</CreationDateTime>
    <Description>phDescription</Description>
    <GroupTab>phTabGroupName</GroupTab>
    <ID>~SET AUTOMATICALLY~</ID>
    <Name>phName</Name>
    <OpenEmbedded>true</OpenEmbedded>
    <SortPriority>100</SortPriority>
    <Status>{123A44CB-7EDC-4ecb-926B-031793668148}</Status>
    <TabTitle>phTabPageTitle</TabTitle>
    <HostDetails>
      <Host>phName</Host>
    </HostDetails>
    <MetaInformation>
      <AssetSubType>Desktop</AssetSubType>
      <Domain>metadomain</Domain>
      <IP>metaIP</IP>
      <Keywords>MyTag1</Keywords>
      <MAC>metamac</MAC>
      <MachineName>metaHost</MachineName>
      <NetworkDHCPRange>MetaDHCPRange</NetworkDHCPRange>
      <NetworkDHCPServer>MetaDHCPServer</NetworkDHCPServer>
      <NetworkFirewallZone>MetaFirewall</NetworkFirewallZone>
      <NetworkGateway>MetaGateway</NetworkGateway>
      <NetworkIPRange>metaIPRange</NetworkIPRange>
      <NetworkSubnet>metaSubnet</NetworkSubnet>
      <NetworkVLANID>MetaVlan</NetworkVLANID>
      <OS>metaos</OS>
    </MetaInformation>
  </Connection>
</ArrayOfConnection>
```

Può notare alcuni oggetti "complessi", ovvero `HostDetails` e `MetaInformation`. Il primo è specifico del tipo di voce ***Host***, mentre il secondo è un contenitore per tutto ciò che si trova nella sezione ***View*** – ***Asset***. Aggiunga il nome della sezione come prefisso per scrivere nei campi interni.

```powershell
Foreach($row in $data)
{
  $session = $RDM.Add($row.Name)
  $session.Kind = "Host"
  $session.HostDetails.Host = $row.Name
  $session.MetaInformation.AssetSubType = "Desktop"
  $session.MetaInformation.IP = "10.10.1.25"
}
```

**Punti chiave**

* Noti che le proprietà `Name` e `HostDetails.Host` condividono lo stesso valore. Questa è una caratteristica della voce ***Host***, e occorre prestare attenzione anche quando si lavora con altri tipi di voce.
* Alcuni campi, come `MetaInformation.AssetSubType`, sono legati a un'enumerazione e devono contenere la stringa esatta. Altri, come `MetaInformation.NetworkGateway`, sono semplici stringhe e possono contenere qualsiasi valore. Non esiti a contattare il nostro [team di supporto](mailto:service@devolutions.net) in caso di ulteriori domande.

**Argomenti correlati**

* [Sincronizzatori](/rdm/it/concepts/advanced-concepts/synchronizers.md)
* [List of property names for PowerShell script](https://docs.devolutions.net/powershell/it/remote-desktop-manager-powershell/powershell-scripting/list-of-property-names-for-powershell-script)
* [PowerShell commands](https://docs.devolutions.net/powershell/it/powershell-commands)


---

# 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/rdm/it/knowledge-base/knowledge-base-articles/entry-settings/custom-powershell-synchronizer.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.
