> 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/es/comandos-de-powershell/set-psucache.md).

# Set-PSUCache

Set-PSUCache almacena un objeto en la caché del lado del servidor de PowerShell Universal, con expiración, persistencia y acceso por roles configurables.

## SINOPSIS

Establece un objeto en la caché del lado del servidor de PowerShell Universal.

## SINTAXIS

### None (predeterminado)

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

## DESCRIPCIÓN

Establece un objeto en la caché del lado del servidor de PowerShell Universal. Este cmdlet se debe usar en APIs, paneles y scripts. No puede recuperar datos de la caché desde la API de gestión.

## EJEMPLOS

### Ejemplo 1

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

Almacena datos en caché para siempre en la caché de nivel de servidor.

### Ejemplo 2

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

Almacena datos en la caché que expirarán en 10 minutos.

### Ejemplo 3

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

Almacena datos en la caché que expirarán en 30 minutos.

### Ejemplo 4

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

Almacena datos en caché con una caché deslizante de 10 minutos. Si no se accede a los datos durante 10 minutos, se invalidarán y se purgarán de la caché. Si se accede a los datos, el temporizador se reiniciará durante otros 10 minutos.

## PARÁMETROS

### -AbsoluteExpiration

Un tiempo de expiración absoluto para los datos en la caché.

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

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

### -AbsoluteExpirationFromNow

Un TimeSpan que indica dentro de cuánto tiempo, a partir de ahora, se deben eliminar los datos de la caché.

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

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

### -Key

Una clave para buscar los datos en la caché.

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

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

### -SlidingExpiration

Un TimeSpan que indica la expiración deslizante de los datos en la caché.

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

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

### -Value

El objeto que se va a almacenar en la caché. Este objeto se serializará a CLIXML.

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

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

### -AppToken

Especifica el token de aplicación que se debe usar al autenticarse en la API de gestión de 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

Especifica la URL o el nombre de host de la instancia de PowerShell Universal de destino. Los nombres de host simples se normalizan a una 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

Ejecuta el comando internamente en lugar de usar la API de gestión. Solo funciona al ejecutar el script desde 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

Proporciona credenciales de Windows al autenticarse en 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

Credenciales para iniciar sesión en la API de gestión de 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

Conserva los datos de la caché en la base de datos.

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

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

### -Role

Los roles que tienen acceso a estos datos en caché.

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

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

### -TrustCertificate

Indica si el cmdlet debe ignorar los problemas de certificado.

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

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

### -Cookies

Reutiliza y conserva las cookies de autenticación para la sesión actual de PowerShell.

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

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

### -Depth

Especifica la profundidad de serialización que se debe usar al convertir los valores antes de enviarlos al servidor.

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

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

### CommonParameters

Este cmdlet admite los parámetros comunes: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -Verbose, -WarningAction, -WarningVariable y -ProgressAction. Para obtener más información, consulte [about\_CommonParameters](http://go.microsoft.com/fwlink/?LinkID=113216).

## ENTRADAS

### Ninguna

## SALIDAS

### System.Object

## NOTAS

## ENLACES RELACIONADOS

[Get-PSUCache](/powershell-universal/es/comandos-de-powershell/get-psucache.md)

## SINOPSIS

Almacena un objeto en la caché del lado del servidor.

## SINTAXIS

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

## DESCRIPCIÓN

Almacena un valor para APIs, paneles y scripts. Use `-Persist` para guardarlo en la base de datos. `-Encrypt` cifra el valor serializado antes de almacenarlo y requiere `-Persist`.

## EJEMPLO

```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/es/comandos-de-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.
