Author | Chrissy LeMaire (@cl), netnerds.net |
Availability | Windows, Linux, macOS |
Want to see the source code for this command? Check out Set-DbaPowerPlan on GitHub.
Want to see the Bill Of Health for this command? Check out Set-DbaPowerPlan.
Configures Windows power plan on SQL Server host computers to optimize database performance.
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/
Set-DbaPowerPlan
[-ComputerName] <DbaInstanceParameter[]>
[[-Credential] <PSCredential>]
[[-PowerPlan] <String>]
[-EnableException]
[-WhatIf]
[-Confirm]
[<CommonParameters>]
PS C:\> Set-DbaPowerPlan -ComputerName sql2017
Sets the Power Plan to High Performance. Skips it if its already set.
PS C:\> 'Server1', 'Server2' | Set-DbaPowerPlan -PowerPlan Balanced
Sets the Power Plan to Balanced for Server1 and Server2. Skips it if its already set.
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.
PS C:\> Set-DbaPowerPlan -ComputerName sqlcluster -PowerPlan 'Maximum Performance'
Sets the Power Plan to "Maximum Performance". Skips it if its already set.
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.
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.
Alias | |
Required | True |
Pipeline | true (ByValue, ByPropertyName) |
Default Value |
Specifies a PSCredential object to use in authenticating to the server(s), instead of the current user account.
Alias | |
Required | False |
Pipeline | true (ByPropertyName) |
Default Value |
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
Alias | CustomPowerPlan,RecommendedPowerPlan |
Required | False |
Pipeline | true (ByPropertyName) |
Default Value |
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.
Alias | |
Required | False |
Pipeline | false |
Default Value | False |
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.
Alias | wi |
Required | False |
Pipeline | false |
Default Value |
If this switch is enabled, you will be prompted for confirmation before executing any operations that change state.
Alias | cf |
Required | False |
Pipeline | false |
Default Value |