---
title: "Set-DbaResourceGovernor"
description: "Configures SQL Server Resource Governor to control workload resource allocation and sets classifier functions."
url: "https://dbatools.io/Set-DbaResourceGovernor/"
availability: "Windows, Linux, macOS"
tags: ["ResourceGovernor"]
author: "John McCall (@lowlydba), lowlydba.com"
source: "https://github.com/dataplat/dbatools/blob/master/public/Set-DbaResourceGovernor.ps1"
last_updated: "2024-01-01"
---

# Set-DbaResourceGovernor

## Synopsis

Configures SQL Server Resource Governor to control workload resource allocation and sets classifier functions.

## Description

Configures Resource Governor settings at the SQL Server instance level to control CPU, memory, and I/O resource allocation for different workloads. Resource Governor requires both being enabled on the instance and having an optional classifier function that determines which resource pool and workload group incoming sessions should use based on login properties, application name, or other criteria.  
  
This function handles the two-step Resource Governor setup process: enabling the feature and optionally assigning a classifier function. The classifier function must be a user-defined function in the master database that returns a workload group name or ID. Without a classifier function, all sessions use the default workload group.  
  
Commonly used when implementing resource management policies to prevent resource-intensive queries from impacting critical applications, or to allocate guaranteed resources to specific users or applications during peak usage periods.

## Syntax

```powershell
Set-DbaResourceGovernor
    [-SqlInstance] <DbaInstanceParameter[]>
    [[-SqlCredential] <PSCredential>]
    [-Enabled]
    [-Disabled]
    [[-ClassifierFunction] <String>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

```

## Examples

### Example 1: Sets Resource Governor to enabled for the instance sql2016

```powershell
PS C:\> Set-DbaResourceGovernor -SqlInstance sql2016 -Enabled
```

### Example 2: Sets Resource Governor to disabled for the instance dev1 on sq2012

```powershell
PS C:\> Set-DbaResourceGovernor -SqlInstance sql2012\dev1 -Disabled
```

### Example 3: Sets Resource Governor to enabled for the instance dev1 on sq2012 and sets the classifier function to be...

```powershell
PS C:\> Set-DbaResourceGovernor -SqlInstance sql2012\dev1 -ClassifierFunction 'fnRGClassifier' -Enabled
```

Sets Resource Governor to enabled for the instance dev1 on sq2012 and sets the classifier function to be 'fnRGClassifier'.  

### Example 4: Sets Resource Governor to enabled for the instance dev1 on sq2012 and sets the classifier function to be NULL

```powershell
PS C:\> Set-DbaResourceGovernor -SqlInstance sql2012\dev1 -ClassifierFunction 'NULL' -Enabled
```

### Required Parameters

##### -SqlInstance

The target SQL Server instance or instances.

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

### Optional Parameters

##### -SqlCredential

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

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

##### -Enabled

Enables Resource Governor on the SQL Server instance to activate workload resource management.  
Use this when you need to enforce resource limits and allocations for different workload groups.

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

##### -Disabled

Disables Resource Governor on the SQL Server instance, removing all resource controls and workload management.  
All sessions will use unlimited resources from the default resource pool when Resource Governor is disabled.

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

##### -ClassifierFunction

Specifies the name of a user-defined function in the master database that determines which workload group incoming sessions should use.  
The function must return a workload group name or ID based on session properties like login name or application name. Use 'NULL' to remove the current classifier function and route all sessions to   
the default workload group.

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

##### -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

**Microsoft.SqlServer.Management.Smo.ResourceGovernor**

Returns the modified Resource Governor object reflecting the new enabled/disabled state and classifier function assignment. Output is piped from Get-DbaResourceGovernor which provides detailed configuration details.

**Default display properties (via Get-DbaResourceGovernor):**

- ComputerName: The computer name of the SQL Server instance
- InstanceName: The SQL Server instance name
- SqlInstance: The full SQL Server instance name (computer\instance)
- Enabled: Boolean indicating if Resource Governor is currently enabled
- ClassifierFunction: Name of the classifier function currently assigned (NULL if none)
- RecoveryPriority: Recovery priority setting for resource allocation
- State: Current state of the Resource Governor (Existing, Creating, etc.)
All properties from the base SMO ResourceGovernor object are accessible using Select-Object *.

---

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