> 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-universal/it/config/agent.md).

# Agent

Gli agent di PowerShell Universal forniscono un meccanismo per eseguire script su computer remoti senza dover configurare PowerShell Remoting. Gli agent sono servizi leggeri che ospitano l'SDK di PowerShell e si connettono a PowerShell Universal utilizzando i WebSocket.

Può scoprire come inviare comandi agli agent nella [pagina Event Hubs](/powershell-universal/it/api/event-hubs.md).

## Installazione

Può trovare maggiori informazioni sull'installazione dell'agent nella nostra [pagina di installazione](/powershell-universal/it/getting-started.md).

## agent.json

Dopo aver installato l'agent, dovrà configurare il client utilizzando un file `agent.json`. Se il file non esiste, dovrà crearlo.

Questo file JSON configura l'agent affinché si connetta all'hub ed esegua gli script quando viene richiamato.

```json
{
    "Connections": [
        {
            "Url": "http://localhost:5000",
            "Hub": "eventHub",
            "AppToken": "tokenXyz",
            "ScriptPath": "script.ps1",
            "Description": "My agent"
        }
    ]
}
```

### Posizione

#### Sistema

La posizione di sistema di `agent.json` è in `$ENV:ProgramData\PowerShellUniversal`.

#### Utente

La posizione specifica dell'utente di `agent.json` è in `$ENV:AppData\PowerShellUniversal.`

### Opzioni

Le opzioni seguenti possono essere incluse nel file `agent.json`.

#### Connections

Queste sono le connessioni agli Event Hub. Ogni connessione può contenere il proprio URL, hub, autenticazione e script da eseguire.

#### URL (obbligatorio)

L'URL del servizio PowerShell Universal.

#### Hub (obbligatorio)

Il nome dell'Event Hub.

#### AppToken

Il token dell'app utilizzato per l'autenticazione presso l'hub.

#### UseDefaultCredentials

Per l'autenticazione presso l'hub verrà utilizzata l'autenticazione di Windows.

#### ScriptPath

Lo script da eseguire quando viene ricevuto un evento. Questo script viene letto in memoria e non da disco. Variabili come `$PSScriptRoot` non sono attualmente supportate. Questo è facoltativo, poiché gli event hub possono anche eseguire comandi direttamente.

Se `ScriptPath` è un percorso relativo come `script.ps1`, l'agent lo risolve relativamente alla directory dei dati di PowerShell Universal. Su Windows, ciò significa `%ProgramData%\PowerShellUniversal\script.ps1`, a meno che non fornisca un percorso completo.

#### Description

La descrizione di questa connessione. Verrà segnalata al server PowerShell Universal.

## Variabili d'ambiente

Le variabili d'ambiente possono essere utilizzate per configurare varie impostazioni operative dell'agent.

| Nome                              | Descrizione                                                        | Valore predefinito |
| --------------------------------- | ------------------------------------------------------------------ | ------------------ |
| PSU\_AgentLogLevel                | Imposta il livello di log per il servizio agent.                   | Information        |
| PSU\_Connections\_\_0\_\_Url      | L'URL del servizio PowerShell Universal.                           |                    |
| PSU\_Connections\_\_0\_\_Hub      | Il nome dell'Event Hub a cui connettersi.                          |                    |
| PSU\_Connections\_\_0\_\_AppToken | Il token dell'app utilizzato per connettersi a un hub autenticato. |                    |


---

# 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-universal/it/config/agent.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.
