Thor Logo dbatools

Set-DbaPowerPlan

View Source
Chrissy LeMaire (@cl), netnerds.net
Windows, Linux, macOS

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

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

 

Examples

 

Example: 1
PS C:\> Set-DbaPowerPlan -ComputerName sql2017

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

Example: 2
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
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
PS C:\> Set-DbaPowerPlan -ComputerName sqlcluster -PowerPlan 'Maximum Performance'

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

Example: 5
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.

PropertyValue
Alias
RequiredTrue
Pipelinetrue (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.

PropertyValue
Alias
RequiredFalse
Pipelinetrue (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 -List to see all available power plans on each computer before setting.

PropertyValue
AliasCustomPowerPlan,RecommendedPowerPlan
RequiredFalse
Pipelinetrue (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.

PropertyValue
Alias
RequiredFalse
Pipelinefalse
Default ValueFalse
-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.

PropertyValue
Aliaswi
RequiredFalse
Pipelinefalse
Default Value
-Confirm

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

PropertyValue
Aliascf
RequiredFalse
Pipelinefalse
Default Value