> 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/set-psucache.md).

# Set-PSUCache

Set-PSUCache archivia un oggetto nella cache lato server di PowerShell Universal, con scadenza, persistenza e accesso ai ruoli configurabili.

## SYNOPSIS

Imposta un oggetto nella cache lato server di PowerShell Universal.

## SINTASSI

### Nessuno (predefinito)

```
Set-PSUCache -Key <String> -Value <Object> [-Persist] [-Role <String[]>] [-Depth <Int32>]
 [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>] [-UseDefaultCredentials]
 [-Integrated] [-TrustCertificate] [-Cookies] [<CommonParameters>]
```

### Absolute

```
Set-PSUCache -Key <String> -Value <Object> [-AbsoluteExpiration <DateTime>] [-Persist] [-Role <String[]>]
 [-Depth <Int32>] [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]
```

### AbsoluteExpirationFromNow

```
Set-PSUCache -Key <String> -Value <Object> [-AbsoluteExpirationFromNow <TimeSpan>] [-Persist]
 [-Role <String[]>] [-Depth <Int32>] [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]
```

### SlidingExpiration

```
Set-PSUCache -Key <String> -Value <Object> [-SlidingExpiration <TimeSpan>] [-Persist] [-Role <String[]>]
 [-Depth <Int32>] [-ComputerName <String>] [-AppToken <String>] [-Credential <PSCredential>]
 [-UseDefaultCredentials] [-Integrated] [-TrustCertificate] [-Cookies]
 [<CommonParameters>]
```

## DESCRIZIONE

Imposta un oggetto nella cache lato server di PowerShell Universal. Questo cmdlet è destinato all'uso all'interno di API, Dashboard e Script. Non è possibile recuperare i dati della cache dall'API di gestione.

## ESEMPI

### Esempio 1

```powershell
PS C:\> Set-PSUCache -Key 'Data' -Value 'MyValue'
```

Memorizza i dati in modo permanente nella cache a livello di server.

### Esempio 2

```powershell
PS C:\> Set-PSUCache -Key 'Data' -Value 'MyValue' -AbsoluteExpiration (Get-Date).AddMinutes(10)
```

Memorizza i dati nella cache con scadenza dopo 10 minuti.

### Esempio 3

```powershell
PS C:\> Set-PSUCache -Key 'Data' -Value 'MyValue' -AbsoluteExpirationFromNow [TimeSpan]::FromMinutes(30)
```

Memorizza i dati nella cache con scadenza dopo 30 minuti.

### Esempio 4

```powershell
PS C:\> Set-PSUCache -Key 'Data' -Value 'MyValue' -SlidingExpiration [TimeSpan]::FromMinutes(10)
```

Memorizza i dati con una cache scorrevole di 10 minuti. Se i dati non vengono consultati per 10 minuti, verranno invalidati ed eliminati dalla cache. Se i dati vengono consultati, il timer si azzera per altri 10 minuti.

## PARAMETRI

### -AbsoluteExpiration

Un'ora di scadenza assoluta per i dati nella cache.

```yaml
Type: DateTime
Parameter Sets: Absolute
Aliases:

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

### -AbsoluteExpirationFromNow

Un valore TimeSpan che indica dopo quanto tempo, a partire da ora, i dati devono essere rimossi dalla cache.

```yaml
Type: TimeSpan
Parameter Sets: AbsoluteExpirationFromNow
Aliases:

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

### -Key

Una chiave per cercare i dati nella cache.

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

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

### -SlidingExpiration

Un valore TimeSpan che indica la scadenza scorrevole per i dati nella cache.

```yaml
Type: TimeSpan
Parameter Sets: SlidingExpiration
Aliases:

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

### -Value

L'oggetto da archiviare nella cache. Questo oggetto verrà serializzato in CLIXML.

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

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

### -AppToken

Specifica il token dell'app da utilizzare per l'autenticazione all'API di gestione di PowerShell Universal.

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

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

### -ComputerName

Specifica l'URL o il nome host dell'istanza di PowerShell Universal di destinazione. I nomi host semplici vengono normalizzati in un URL `http://<host>:5000`.

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

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

### -Integrated

Esegue il comando internamente invece di utilizzare l'API di gestione. Funziona solo quando lo script viene eseguito dall'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
```

### -UseDefaultCredentials

Fornisce le credenziali di Windows durante l'autenticazione a PowerShell Universal.

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

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

### -Credential

Credenziali per accedere all'API di gestione di PowerShell Universal.

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

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

### -Persist

Rende persistenti i dati della cache nel database.

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

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

### -Role

I ruoli che hanno accesso a questi dati memorizzati nella cache.

```yaml
Type: String[]
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
```

### -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
```

### -Depth

Specifica la profondità di serializzazione da utilizzare per la conversione dei valori prima dell'invio al server.

```yaml
Type: Int32
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 maggiori informazioni, veda [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## INPUT

### Nessuno

## OUTPUT

### System.Object

## NOTE

## COLLEGAMENTI CORRELATI

[Get-PSUCache](/powershell-universal/it/comandi-powershell/get-psucache.md)

## SYNOPSIS

Archivia un oggetto nella cache lato server.

## SINTASSI

```powershell
Set-PSUCache -Key <String> -Value <Object> [-Persist] [-Encrypt] [-ReaderRole <String[]>] [-Depth <Int32>]
```

## DESCRIZIONE

Archivia un valore per API, dashboard e script. Utilizzi `-Persist` per salvarlo nel database. `-Encrypt` crittografa il valore serializzato prima dell'archiviazione e richiede `-Persist`.

## ESEMPIO

```powershell
Set-PSUCache -Key 'Data' -Value 'MyValue' -Persist -Encrypt
```


---

# 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/set-psucache.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.
