﻿---
title: stack kb elastic-agent-actions post-fleet-agents-bulk-unenroll cli command
description: Bulk unenroll agents 
url: https://www.elastic.co/elastic/docs-builder/docs/4948/reference/elastic-cli/cli/stack/kb/elastic-agent-actions/post-fleet-agents-bulk-unenroll
applies_to:
  - Elastic Cloud Serverless: Preview
  - Elastic Stack: Preview
---

# stack kb elastic-agent-actions post-fleet-agents-bulk-unenroll cli command
<cli-modifiers>
</cli-modifiers>

```bash
elastic stack kb elastic-agent-actions post-fleet-agents-bulk-unenroll \
  --agents <agents> \
  [options]
```

Bulk unenroll agents

## Options

<definitions>
  <definition term="--agents string required">
    **Repeatable:** pass `--agents` multiple times to supply more than one value
  </definition>
  <definition term="--batch-size number">
  </definition>
  <definition term="--dry-run">
  </definition>
  <definition term="--force">
    Also unenrolls agents that are enrolled in hosted agent policies or are managed agents. Does not revoke API keys immediately. To do so, also set `revoke`.
  </definition>
  <definition term="--include-inactive">
    When passing agents by KQL query, unenrolls inactive agents too
  </definition>
  <definition term="--revoke">
    Immediately invalidates the API keys of the agents without notifying them. The agents keep running and can still send data to outputs not covered by the invalidated keys, such as Kafka and Logstash. Remote Elasticsearch keys are invalidated by Fleet Server on a best-effort basis. This action cannot be undone. Use it only for offline or compromised agents.
  </definition>
  <definition term="--input-file string">
    path to a JSON file to use as command input
  </definition>
  <definition term="--no-validate">
    skip input validation and send the request as-is
  </definition>
</definitions>


## Global Options

<definitions>
  <definition term="--output-fields string">
    comma-separated list of fields to include in output (dot-notation supported)
  </definition>
  <definition term="--output-template string">
    Mustache-like template for custom text output (e.g. "{{id}}: {{name}}")
  </definition>
  <definition term="--json">
    output as JSON
  </definition>
</definitions>