---
title: "Set-DbaPowerPlan"
description: "Configures Windows power plan on SQL Server host computers to optimize database performance."
url: "https://dbatools.io/Set-DbaPowerPlan/"
availability: "Windows only"
tags: ["PowerPlan", "OS", "Configure", "Utility"]
author: "Chrissy LeMaire (@cl), netnerds.net"
source: "https://github.com/dataplat/dbatools/blob/master/public/Set-DbaPowerPlan.ps1"
last_updated: "2024-01-01"
---

# Set-DbaPowerPlan

## Synopsis

Configures Windows power plan on SQL Server host computers to optimize database performance.

## Description

Changes the Windows power plan on SQL Server host machines using WMI and PowerShell remoting. Defaults to High Performance, which prevents CPU throttling that can severely impact database query performance and response times.  
  
Windows power plans control CPU frequency scaling, and the default "Balanced" plan can cause significant performance degradation under SQL Server workloads. This function ensures your SQL Server hosts are configured for optimal performance rather than power savings.  
  
If your organization has a custom power plan considered best practice, you can specify it with -PowerPlan. The function will skip computers that already have the target power plan active.  
  
References:  
https://support.microsoft.com/en-us/kb/2207548  
http://www.sqlskills.com/blogs/glenn/windows-power-plan-effects-on-newer-intel-processors/

## Syntax

```powershell
Set-DbaPowerPlan
    [-ComputerName] <DbaInstanceParameter[]>
    [[-Credential] <PSCredential>]
    [[-PowerPlan] <String>]
    [-EnableException]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

```

## Examples

### Example 1: Sets the Power Plan to High Performance

```powershell
PS C:\> Set-DbaPowerPlan -ComputerName sql2017
```

Sets the Power Plan to High Performance. Skips it if its already set.  

### Example 2: Sets the Power Plan to Balanced for Server1 and Server2

```powershell
PS C:\> 'Server1', 'Server2' | Set-DbaPowerPlan -PowerPlan Balanced
```

Sets the Power Plan to Balanced for Server1 and Server2. Skips it if its already set.  

### Example 3: Connects using alternative Windows credential and sets the Power Plan to High Performance

```powershell
PS C:\> $cred = Get-Credential 'Domain\User'
PS C:\> Set-DbaPowerPlan -ComputerName sql2017 -Credential $cred
```

Connects using alternative Windows credential and sets the Power Plan to High Performance. Skips it if its already set.  

### Example 4: Sets the Power Plan to &quot;Maximum Performance&quot;

```powershell
PS C:\> Set-DbaPowerPlan -ComputerName sqlcluster -PowerPlan 'Maximum Performance'
```

Sets the Power Plan to "Maximum Performance". Skips it if its already set.  

### Example 5: Uses the Power Plan of oldserver as best practice and sets the Power Plan of newserver1 and newserver2...

```powershell
PS C:\> Get-DbaPowerPlan -ComputerName oldserver | Set-DbaPowerPlan -ComputerName newserver1, newserver2
```

Uses the Power Plan of oldserver as best practice and sets the Power Plan of newserver1 and newserver2 accordingly.  

### Required Parameters

##### -ComputerName

Specifies the Windows host computers where SQL Server instances are running to configure the power plan.  
Accepts multiple server names and connects via WMI and PowerShell remoting to change OS-level power settings.  
Use the actual Windows computer names, not SQL Server instance names.

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

### Optional Parameters

##### -Credential

Specifies a PSCredential object to use in authenticating to the server(s), instead of the current user account.

| Property | Value |
| --- | --- |
| Alias |  |
| Required | False |
| Pipeline | true (ByPropertyName) |
| Default Value |  |

##### -PowerPlan

Specifies the Windows power plan to set on the target computers. Defaults to "High Performance" when not specified.  
Use this when your organization has a custom power plan or specific requirements beyond the default recommendation.  
Run Get-DbaPowerPlan -ComputerName <server> -List to see all available power plans on each computer before setting.

| Property | Value |
| --- | --- |
| Alias | CustomPowerPlan,RecommendedPowerPlan |
| Required | False |
| Pipeline | true (ByPropertyName) |
| 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

If this switch is enabled, no actions are performed but informational messages will be displayed that explain what would happen if the command were to run.

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

##### -Confirm

If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.

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

## Outputs

**PSCustomObject**

Returns one object per computer processed, containing the power plan configuration result. The object shows the power plan before and after the operation, allowing you to verify which computers had their power plan changed.

**Default display properties (via Select-DefaultView):**

- ComputerName: The target computer name
- PreviousPowerPlan: The name of the power plan that was active before the operation
- ActivePowerPlan: The name of the current active power plan (same as PreviousPowerPlan if no change, updated if changed)
- IsChanged: Boolean indicating whether the power plan was changed (True if changed, False if already set to the target plan)

**Additional properties available using Select-Object *:**

- PreviousInstanceId: The unique GUID identifier of the power plan that was active before the operation
- ActiveInstanceId: The unique GUID identifier of the current active power plan

---

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