> 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-psuscript.md).

# New-PSUScript

## SINOSSI

Crea un nuovo script in PowerShell Universal.

## SINTASSI

### ScriptBlock

```
New-PSUScript -ScriptBlock <ScriptBlock> [-ManualTime <Int32>] [-TimeOut <Double>] -Name <String>
 [-Description <String>] [-Parameter <ScriptParameter[]>] [-Tag <Tag[]>] [-Status <ScriptStatus>]
 [-Environment <String>] [-Notes <String>] [-DisableManualInvocation] [-Path <String>] [-MaxHistory <Int32>]
 [-ConcurrentJobs <Int32>] [-Credential <Variable>] [-RetryLimit <Int32>] [-DiscardPipeline] [-LoadProfile]
 [-WorkingDirectory <String>] [-Role <String[]>] [-PortalOutputType <PortalOutputType>]
 [-AvailableInBranch <String[]>] [-PortalOpenInNewWindow] [-Icon <String>]
 [-PortalBehavior <ScriptPortalBehavior>] [-PortalLeaveForm] [-DisplayOutputOnExecute]
 [-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
 [-Integrated] [-TrustCertificate] [-Cookies] [<CommonParameters>]
```

### Path

```
New-PSUScript [-ManualTime <Int32>] [-TimeOut <Double>] -Name <String> [-Description <String>]
 [-Parameter <ScriptParameter[]>] [-Tag <Tag[]>] [-Status <ScriptStatus>] [-Environment <String>]
 [-Notes <String>] [-DisableManualInvocation] -Path <String> [-MaxHistory <Int32>] [-ConcurrentJobs <Int32>]
 [-Credential <Variable>] [-RetryLimit <Int32>] [-DiscardPipeline] [-LoadProfile] [-WorkingDirectory <String>]
 [-Role <String[]>] [-PortalOutputType <PortalOutputType>] [-AvailableInBranch <String[]>]
 [-PortalOpenInNewWindow] [-Icon <String>] [-PortalBehavior <ScriptPortalBehavior>] [-PortalLeaveForm]
 [-DisplayOutputOnExecute] [-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]
```

### Module

```
New-PSUScript [-ManualTime <Int32>] [-TimeOut <Double>] [-Description <String>]
 [-Parameter <ScriptParameter[]>] [-Tag <Tag[]>] [-Status <ScriptStatus>] [-Environment <String>]
 [-Notes <String>] [-DisableManualInvocation] [-MaxHistory <Int32>] [-ConcurrentJobs <Int32>]
 [-Credential <Variable>] [-RetryLimit <Int32>] [-DiscardPipeline] [-LoadProfile] [-WorkingDirectory <String>]
 -Module <String> -Command <String> [-Role <String[]>] [-PortalOutputType <PortalOutputType>]
 [-AvailableInBranch <String[]>] [-PortalOpenInNewWindow] [-Icon <String>]
 [-PortalBehavior <ScriptPortalBehavior>] [-PortalLeaveForm] [-DisplayOutputOnExecute]
 [-ExecutionRole <String[]>] [-ComputerName <String>] [-AppToken <String>] [-UseDefaultCredentials]
 [-Integrated] [-TrustCertificate] [-Cookies] [<CommonParameters>]
```

## DESCRIZIONE

Crea un nuovo script in PowerShell Universal. Gli script possono essere eseguiti manualmente o pianificati all'interno di PSU. Gli script creati in base al contenuto verranno scritti nella directory del repository. Gli script creati tramite percorso verranno referenziati da tale percorso.

Le configurazioni degli script sono archiviate in .universal/scripts.ps1

È inoltre possibile utilizzare questo cmdlet per creare script tramite l'API REST.

## ESEMPI

### Esempio 1

```
New-PSUScript -Name 'Script1.ps1' -Path 'Script1.ps1'
```

Crea uno script in PSU che fa riferimento a un percorso relativo di Script1.ps1 nella cartella del repository.

### Esempio 2

```
New-PSUScript -Name 'Script1.ps1' -ScriptBlock {
    "Hello, world!"
}
```

Crea uno script in PSU basato sul blocco di script fornito. In questo modo verrà creato un file Script1.ps1 all'interno della directory del repository.

## PARAMETRI

### -AppToken

L'AppToken utilizzato per chiamare l'API di gestione di PowerShell Universal. È inoltre possibile chiamare Connect-PSUServer prima di questo cmdlet per impostare l'AppToken per l'intera sessione.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ComputerName

Specifica il nome del computer o l'URL da chiamare quando si accede all'API di gestione di PowerShell Universal. È inoltre possibile utilizzare Connect-PSUServer prima di chiamare questo cmdlet per impostare il nome del computer per l'intera sessione.

```yaml
Type: String
Parameter Sets: (All)
Aliases: Uri

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Description

La descrizione dello script.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisableManualInvocation

Disabilita l'invocazione manuale dello script. Lo script può essere eseguito solo in base a una pianificazione.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: False
Accept pipeline input: False
Accept wildcard characters: False
```

### -ManualTime

Il tempo necessario per eseguire manualmente questo specifico script.

```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -MaxHistory

La cronologia massima dei processi per questo script. Il valore predefinito è 100.

```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Name

Il nome di questo script.

```yaml
Type: String
Parameter Sets: ScriptBlock, Path
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Notes

Note da includere con questo script.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Parameter

Obsoleto

```yaml
Type: ScriptParameter[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Path

Il percorso dello script. Può essere un percorso relativo alla directory del repository o un percorso assoluto.

```yaml
Type: String
Parameter Sets: ScriptBlock
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

```yaml
Type: String
Parameter Sets: Path
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ScriptBlock

Un blocco di script da definire per questo script.

```yaml
Type: ScriptBlock
Parameter Sets: ScriptBlock
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Status

Non utilizzato.

```yaml
Type: ScriptStatus
Parameter Sets: (All)
Aliases:
Accepted values: Draft, Pending_Review, Published, Disabled

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Tag

Tag da assegnare a questo script.

```yaml
Type: Tag[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ConcurrentJobs

Il numero di processi simultanei consentiti per questo script. Per impostazione predefinita, non è previsto alcun limite.

```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Environment

L'ambiente in cui eseguire questo script.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -TimeOut

Il numero di minuti prima che i processi basati su questo script vadano in timeout.

```yaml
Type: Double
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Credential

La variabile delle credenziali utente da utilizzare durante l'esecuzione di questo script.

```yaml
Type: Variable
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -UseDefaultCredentials

Utilizza le credenziali predefinite durante la connessione all'API di gestione

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Integrated

Esegue il comando internamente anziché tramite l'API di gestione. Funziona solo quando lo script viene eseguito all'interno di PowerShell Universal.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -RetryLimit

Il numero di tentativi di riesecuzione di questo script in caso di errore.

```yaml
Type: Int32
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DiscardPipeline

Indica se scartare l'output della pipeline anziché renderlo persistente nel database.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -LoadProfile

Carica il profilo utente quando si esegue questo script come un altro utente.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -WorkingDirectory

La directory di lavoro dello script.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Command

Il comando che definisce questo script.

```yaml
Type: String
Parameter Sets: Module
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Module

Il modulo che contiene il comando che definisce questo script.

```yaml
Type: String
Parameter Sets: Module
Aliases:

Required: True
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Role

Il ruolo necessario per eseguire questo script.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -AvailableInBranch

Se specificato, questo script sarà disponibile solo nei branch indicati.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PortalOutputType

Il tipo di output del portale da visualizzare durante l'esecuzione di questo script nel portale.

```yaml
Type: PortalOutputType
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -TrustCertificate

Indica se il cmdlet deve ignorare i problemi relativi ai certificati.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PortalOpenInNewWindow

Indica se aprire questo script in una nuova finestra durante la visualizzazione nel portale.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Icon

Un'icona da visualizzare nel portale.

```yaml
Type: String
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -DisplayOutputOnExecute

Visualizza l'output dello script mentre viene eseguito nel portale.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PortalBehavior

Il comportamento di questo script nel portale.

```yaml
Type: ScriptPortalBehavior
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -PortalLeaveForm

Indica se uscire dal modulo dello script dopo averlo eseguito nel portale.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -Cookies

Riutilizza e rende persistenti i cookie di autenticazione per la sessione PowerShell corrente.

```yaml
Type: SwitchParameter
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### -ExecutionRole

Specifica uno o più ruoli che possono eseguire la risorsa.

```yaml
Type: String[]
Parameter Sets: (All)
Aliases:

Required: False
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False
```

### CommonParameters

Questo cmdlet supporta i parametri comuni: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable e -ProgressAction. Per ulteriori informazioni, veda [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUT

### None

## OUTPUT

### System.Object

## NOTE

## COLLEGAMENTI CORRELATI

[Get-PSUScript](https://github.com/Devolutions/docs/tree/master/translations/it/powershell-universal/cmdlets/Get-PSUScript/README.md) [Remove-PSUScript](https://github.com/Devolutions/docs/tree/master/translations/it/powershell-universal/cmdlets/Remove-PSUScript/README.md) [Invoke-PSUScript](https://github.com/Devolutions/docs/tree/master/translations/it/powershell-universal/cmdlets/Invoke-PSUScript/README.md) [Set-PSUScript](https://github.com/Devolutions/docs/tree/master/translations/it/powershell-universal/cmdlets/Set-PSUScript/README.md) [Get-PSUEnvironment](https://github.com/Devolutions/docs/tree/master/translations/it/powershell-universal/cmdlets/Get-PSUEnvironment/README.md)


---

# 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/comandi-powershell/new-psuscript.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.
