> 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/powershell-commands/set-psuaiagent.md).

# Set-PSUAiAgent

Set-PSUAiAgent updates an existing AI agent in PowerShell Universal, modifying only the fields you supply, such as instructions, model, or tools.

## SYNOPSIS

Updates an existing AI agent definition.

## SYNTAX

```powershell
Set-PSUAiAgent -Id <Int64> [-Name <String>] [-Description <String>] [-Instructions <String>] [-Model <String>] [-ApiKey <Variable>] [-Provider <AiProvider>] [-Endpoint <String>] [-Tool <String[]>] [-Role <String[]>] [-AvailableInChat] [<ConnectionOptions>] [<CommonParameters>]
Set-PSUAiAgent -AiAgent <AiAgent> [-Name <String>] [-Description <String>] [-Instructions <String>] [-Model <String>] [-ApiKey <Variable>] [-Provider <AiProvider>] [-Endpoint <String>] [-Tool <String[]>] [-Role <String[]>] [-AvailableInChat] [<ConnectionOptions>] [<CommonParameters>]
```

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

## DESCRIPTION

Loads an agent by ID or pipeline object and updates only the supplied fields. Supplying `-Tool` replaces the allowed tool list; `-AvailableInChat` controls whether the agent appears in admin and generated-app chat pickers. The provider can be `OpenAI`, `Anthropic`, or `Custom`; when the resulting provider is `Custom`, its endpoint must be an absolute URL.

## EXAMPLES

```powershell
Set-PSUAiAgent -Id 12 -Instructions 'Escalate billing issues to humans.' -Tool GetInvoices,CreateTicket
Set-PSUAiAgent -Id 12 -AvailableInChat -Tool GetTickets,CreateTicket
```

## PARAMETERS

| Parameter                | Description                                                           |
| ------------------------ | --------------------------------------------------------------------- |
| `-Id`                    | Numeric ID of the agent to update.                                    |
| `-AiAgent`               | Agent object to update; accepts pipeline input.                       |
| `-Name`                  | New agent name.                                                       |
| `-Description`           | New description.                                                      |
| `-Instructions`          | New system instructions.                                              |
| `-Model`                 | New model identifier.                                                 |
| `-ApiKey`                | PSU variable containing the provider API key.                         |
| `-Provider`              | AI provider: `OpenAI`, `Anthropic`, or `Custom`.                      |
| `-Endpoint`              | Absolute provider URL required if the resulting provider is `Custom`. |
| `-Tool`                  | Replacement list of allowed tool names (alias `-Tools`).              |
| `-Role`                  | Replacement list of allowed roles (alias `-Roles`).                   |
| `-AvailableInChat`       | Set availability in chat UI.                                          |
| `-ComputerName`          | Target server URL or host name (alias `-Uri`).                        |
| `-AppToken`              | Management API app token.                                             |
| `-Credential`            | Credentials for Management API Basic authentication.                  |
| `-UseDefaultCredentials` | Uses current Windows credentials.                                     |
| `-Integrated`            | Uses the in-process management client.                                |
| `-TrustCertificate`      | Ignores certificate validation errors.                                |
| `-Cookies`               | Reuses session authentication cookies.                                |

## INPUTS

`PowerShellUniversal.Models.Intelligence.AiAgent`.

## PERMISSIONS

The access token requires `intelligence.agents/update` to run this cmdlet remotely.


---

# 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/powershell-commands/set-psuaiagent.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.
