# Toggle Drain Mode

### Description

This Runbooks looks through all AVD Hostpools of a tenant and sets the DrainMode for a specific Session Host. The SubscriptionId value must be defined in the runbooks customization.

### Location

Device → AVD → Toggle Drain Mode

**Full Runbook name**

rjgit-device\_AVD\_toggle-drain-mode

### Permissions

#### Permission notes

Azure: Desktop Virtualization Host Pool Contributor on Subscription which contains the Hostpool

### Parameters

#### DeviceName

The name of the AVD Session Host device for which to toggle drain mode. Hidden in UI.

| Property      | Value  |
| ------------- | ------ |
| Required      | true   |
| Default Value |        |
| Type          | String |

#### DrainMode

Boolean value to enable or disable Drain Mode. Set to true to enable Drain Mode (prevent new sessions), false to disable it (allow new sessions). Default is false.

| Property      | Value   |
| ------------- | ------- |
| Required      | true    |
| Default Value | False   |
| Type          | Boolean |

#### SubscriptionIds

Array of Azure subscription IDs where the AVD Session Host resources are located. Retrieved from AVD.SubscriptionIds setting (Customization). Hidden in UI.

| Property      | Value     |
| ------------- | --------- |
| Required      | true      |
| Default Value |           |
| Type          | String\[] |

[Back to Runbook Reference overview](https://docs.realmjoin.com/automation/runbooks/runbook-references)


---

# Agent Instructions: 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:

```
GET https://docs.realmjoin.com/automation/runbooks/runbook-references/device/avd/toggle-drain-mode.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
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.
