> 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/comandi-powershell/new-psutrigger.md).

# New-PSUTrigger

New-PSUTrigger crea un trigger di automazione in PowerShell Universal che esegue uno script in risposta a eventi come gli errori dei job o l'arresto delle dashboard.

## SINOSSI

Crea un trigger di automazione.

## SINTASSI

```powershell
New-PSUTrigger -Name <String> -EventType <EventType> -TriggerScript <Script> [-Script <Script>] [-Scripts <Script[]>] [-Dashboard <Dashboard>] [-Environment <String>] [-Delay <Int32>] [-Computer <String>] [-Condition <ScriptBlock>] [-Parameters <Hashtable>] [<ConnectionOptions>] [<CommonParameters>]
```

`<ConnectionOptions>`: `[-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]`.

## DESCRIZIONE

Crea un trigger che esegue uno script di trigger per gli eventi PSU. Usi `-Script` o `-Scripts` per associare uno o più script ai trigger di eventi di job; se sono indicati entrambi, `-Scripts` ha la precedenza. `-Parameters` fornisce una hashtable allo script di trigger e risolve i suoi parametri dichiarati. Facoltativamente, filtri l'esecuzione con `-Condition`.

## ESEMPIO

```powershell
New-PSUTrigger -Name 'Build failures' -EventType JobFailed -Scripts 'Build.ps1','Deploy.ps1' -TriggerScript 'Notify.ps1' -Parameters @{ Channel = 'ops' }
```

## PARAMETRI

| Parametro                | Descrizione                                                              |
| ------------------------ | ------------------------------------------------------------------------ |
| `-Name`                  | Nome del trigger obbligatorio.                                           |
| `-EventType`             | Tipo di evento PSU obbligatorio che attiva il trigger.                   |
| `-TriggerScript`         | Script obbligatorio che viene eseguito quando si verifica l'evento.      |
| `-Script`                | Uno script associato per il filtro degli eventi.                         |
| `-Scripts`               | Più script associati per il filtro degli eventi.                         |
| `-Dashboard`             | App associata all'evento.                                                |
| `-Environment`           | Ambiente di esecuzione dello script di trigger.                          |
| `-Delay`                 | Ritardo prima di eseguire il trigger.                                    |
| `-Computer`              | Computer o gruppo di esecuzione.                                         |
| `-Condition`             | Blocco di script di condizione che deve essere soddisfatto.              |
| `-Parameters`            | Valori dei parametri dello script di trigger.                            |
| `-ComputerName`          | URL o nome host dell'API di gestione PSU di destinazione (alias `-Uri`). |
| `-AppToken`              | Token dell'app dell'API di gestione.                                     |
| `-Credential`            | Credenziali dell'API di gestione.                                        |
| `-UseDefaultCredentials` | Usa le credenziali Windows correnti.                                     |
| `-Integrated`            | Usa il client di gestione nel processo.                                  |
| `-TrustCertificate`      | Ignora gli errori di convalida del certificato.                          |
| `-Cookies`               | Riutilizza i cookie di autenticazione della sessione.                    |

## AUTORIZZAZIONI

Il token di accesso richiede `automation.triggers/create` per eseguire questo cmdlet in remoto.


---

# 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-universal/it/comandi-powershell/new-psutrigger.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.
