---
title: "Disable-DbaAgHadr"
description: "Disables High Availability Disaster Recovery (HADR) capability on SQL Server instances."
url: "https://dbatools.io/Disable-DbaAgHadr/"
availability: "Windows only"
tags: ["AG", "HA"]
author: "Shawn Melton (@wsmelton), wsmelton.github.io"
source: "https://github.com/dataplat/dbatools/blob/master/public/Disable-DbaAgHadr.ps1"
last_updated: "2024-01-01"
---

# Disable-DbaAgHadr

## Synopsis

Disables High Availability Disaster Recovery (HADR) capability on SQL Server instances.

## Description

Disables the HADR service setting at the SQL Server instance level, effectively removing the instance's ability to participate in Availability Groups. This is commonly needed when decommissioning servers from AGs, troubleshooting AG setup issues, or converting instances back to standalone operation after removing them from Availability Groups.  
  
The function modifies the HADR setting through WMI but requires a SQL Server service restart to take effect. Use the -Force parameter to automatically restart both SQL Server and SQL Agent services immediately, or manually restart later to apply the change.

## Syntax

```powershell
Disable-DbaAgHadr
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-Credential] <PSCredential>]
    [-Force]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

```

## Examples

### Example 1: Sets Hadr service to disabled for the instance sql2016 but changes will not be applied until the next time...

```powershell
PS C:\> Disable-DbaAgHadr -SqlInstance sql2016
```

Sets Hadr service to disabled for the instance sql2016 but changes will not be applied until the next time the server restarts.  

### Example 2: Sets Hadr service to disabled for the instance sql2016, and restart the service to apply the change

```powershell
PS C:\> Disable-DbaAgHadr -SqlInstance sql2016 -Force
```

### Example 3: Sets Hadr service to disabled for the instance dev1 on sq2012, and restart the service to apply the change

```powershell
PS C:\> Disable-DbaAgHadr -SqlInstance sql2012\dev1 -Force
```

### Required Parameters

##### -SqlInstance

The target SQL Server instance or instances.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | True |
| Pipeline | true (ByValue) |
| Default Value |  |

### Optional Parameters

##### -Credential

Credential object used to connect to the Windows server as a different user

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Force

Automatically restarts both SQL Server and SQL Server Agent services to immediately apply the HADR setting change. Without this switch, the HADR disable setting is changed but requires manual service   
restart to take effect.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -EnableException

By default, when something goes wrong we try to catch it, interpret it and give you a friendly warning message.  
This avoids overwhelming you with "sea of red" exceptions, but is inconvenient because it basically disables advanced scripting.  
Using this switch turns this "nice by default" feature off and enables you to catch exceptions with your own try/catch.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | false |
| Default Value | False |

##### -WhatIf

Shows what would happen if the command were to run. No actions are actually performed.

| Property | Value |
| --- | --- |
| Alias | wi |
| Required | False |
| Pipeline | false |
| Default Value |  |

##### -Confirm

Prompts you for confirmation before executing any changing operations within the command.

| Property | Value |
| --- | --- |
| Alias | cf |
| Required | False |
| Pipeline | false |
| Default Value |  |

## Outputs

**PSCustomObject**

**Returns one object per successfully processed instance, containing the following properties:**

- ComputerName: The name of the computer hosting the SQL Server instance
- InstanceName: The name of the SQL Server instance (e.g., MSSQLSERVER or named instance)
- SqlInstance: The full SQL Server instance identifier in the format ComputerName\InstanceName
- IsHadrEnabled: Boolean value indicating the HADR status (always $false for successful disable operations)

---

Part of [dbatools](https://dbatools.io/), a free and open source PowerShell module for SQL Server administration. Full command index: https://dbatools.io/commands/
