< Back

Set-DbaPowerPlan

Mon Jan 13, 2020 5:41 pm

NAME Set-DbaPowerPlan



SYNOPSIS

Sets the SQL Server OS's Power Plan.





SYNTAX

Set-DbaPowerPlan [[-ComputerName] <Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>] [[-Credential]

<Pscredential>] [[-PowerPlan] <String>] [[-CustomPowerPlan] <String>] [[-InputObject]

<System.Management.Automation.PSObject[]>] [-EnableException <Switch>] [<CommonParameters>]





DESCRIPTION

Sets the SQL Server OS's Power Plan. Defaults to High Performance which is best practice.



If your organization uses a custom power plan that is considered best practice, specify -CustomPowerPlan.



References:



https://support.microsoft.com/en-us/kb/2207548



http://www.sqlskills.com/blogs/glenn/wi ... rocessors/





PARAMETERS

-ComputerName [<Sqlcollaborative.Dbatools.Parameter.DbaInstanceParameter[]>]

The server(s) to set the Power Plan on.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-Credential [<Pscredential>]

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



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-CustomPowerPlan [<String>]

Specifies the name of a custom Power Plan to use.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-EnableException [<Switch>]

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.



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-InputObject [<System.Management.Automation.PSObject[]>]

Enables piping from Get-DbaPowerPlan



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



-PowerPlan [<String>]

Specifies the Power Plan that you wish to use. Valid options for this match the Windows default Power Plans of

"Power Saver", "Balanced", and "High Performance".



Required? false

Position? named

Default value

Accept pipeline input? False

Accept wildcard characters? false



<CommonParameters>

This cmdlet supports the common parameters: Verbose, Debug,

ErrorAction, ErrorVariable, WarningAction, WarningVariable,

OutBuffer, PipelineVariable, and OutVariable. For more information, see

about_CommonParameters (https:/go.microsoft.com/fwlink/?LinkID=113216).



INPUTS



OUTPUTS



NOTES





Tags: PowerPlan, OS, Configure

Author: Chrissy LeMaire (@cl), netnerds.net



Website: https://dbatools.io

Copyright: (c) 2018 by dbatools, licensed under MIT

License: MIT https://opensource.org/licenses/MIT



Requires: WMI access to servers



-------------------------- 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 -CustomPowerPlan 'Maximum Performance'



Sets the Power Plan to the custom power plan called "Maximum Performance". Skips it if its already set.



RELATED LINKS

https://dbatools.io/Set-DbaPowerPlan