dbatools icon indicating copy to clipboard operation
dbatools copied to clipboard

[Bug] Set-DbaPowerPlan fails on non-english language Windows installations

Open sql-williamd opened this issue 6 years ago • 13 comments

Environmental information

Run below command, paste results below:

#### PowerShell version:

Name                           Value                                                                                   
----                           -----                                                                                   
PSVersion                      5.1.17763.1007                                                                          
PSEdition                      Desktop                                                                                 
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}                                                                 
BuildVersion                   10.0.17763.1007                                                                         
CLRVersion                     4.0.30319.42000                                                                         
WSManStackVersion              3.0                                                                                     
PSRemotingProtocolVersion      2.3                                                                                     
SerializationVersion           1.1.0.1                                                                                 

#### dbatools Module version:
Name    : dbatools
Path    : C:\Program Files\WindowsPowerShell\Modules\dbatools\1.0.100\dbatools.psd1
Version : 1.0.100
LCID             Name             DisplayName
----             ----             -----------
1031             de-DE            Deutsch (Deutschland)

Report

Running Set-DbaPowerPlan on a fresh Windows 2019 Datacenter VM installed with the German language fails to set, because the 'High Performance' plan could not be found by the command.

This is similar to issues #2769 and #245

Host used

  • [x] powershell.exe
  • [ ] ISE
  • [ ] VS Code
  • [ ] Other (please specify)

Errors Received

WARNUNG: [10:03:19][Set-DbaPowerPlanInternal] Couldn't find the requested Power Plan 'High Performance' on SQL2019.

Steps to Reproduce

Windows 2019 Datacenter VM in German (presumably any non-english install) Set-DbaPowerPlan -ComputerName {CompterName}

Expected Behavior

Use the GUID values for the PowerPlan info stored in the registry

Actual Behavior

Fails to load the power plan information from the registry because it is searching for the English language names.

sql-williamd avatar Mar 03 '20 09:03 sql-williamd

Ah, this is by design because we don't know all the different ways to spell it. Our default is English: [string]$PowerPlan = 'High Performance', but you can specify -PowerPlan 'German Phrase'.

potatoqualitee avatar Mar 03 '20 09:03 potatoqualitee

Basically, we chose the convenience for a majority of our users (en) users. We can address by removing the default (not so sure), perhaps translating like Get/Test (up for others to do), or adding an example (easy enough). Ultimately, the command is not wrong, there is indeed no plan named High Performance and setting to "High Performance" is not a requirement, only a default.

I'll fix by adding an example. Please let me know the german phrase for High Performance.

potatoqualitee avatar Mar 03 '20 09:03 potatoqualitee

Alternatively, Test-DbaPowerPlan -ComputerName sql2017 |Set-DbaPowerPlan can likely be used

potatoqualitee avatar Mar 03 '20 09:03 potatoqualitee

Oops that was supposed to be a PR. But this has been fixed in https://github.com/sqlcollaborative/dbatools/commit/37ae326e4b07fd73706e7723d4052ade8598ee92 - i found a german word for high performance from the other issue

potatoqualitee avatar Mar 03 '20 09:03 potatoqualitee

Ok, I'm fine with that, just thought it would grab the GUID for "High Performance" and default to that, instead of the string, if that makes sense.

I push most installs to be in English anyway, but with that example to clarify I think we are good to go :)

sql-williamd avatar Mar 03 '20 09:03 sql-williamd

Yeah, we shouldn't depend on the phrase of a setting because that can be redefined as well with newer versions of the OS.

The GUID for this power setting should be 8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C, documented here: https://docs.microsoft.com/en-us/windows/win32/power/power-setting-guids

wsmelton avatar Mar 03 '20 13:03 wsmelton

(Which I could have sworn we already did this for something.... 🤔 )

wsmelton avatar Mar 03 '20 13:03 wsmelton

🚧🚨 This issue is being marked as stale due to 90 days of inactivity. If you would like this issue to remain open:

  • Verify the issue/bug is reproduced in the latest version of the module
  • Verify the environmental info provided is still accurate
  • Add any additional steps you followed to reproduce if necessary 🚨🚧 ⌛️ This issue will be closed in 30 days ⌛️

github-actions avatar Aug 02 '20 06:08 github-actions

@wsmelton will you open a PR for that or should we close this?

andreasjordan avatar May 19 '21 10:05 andreasjordan

Hi Shawn, can you tell me a litte bit about your plans on this issue?

andreasjordan avatar Jun 05 '21 12:06 andreasjordan

Seems we have code to support 8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C in Test but not Set.

I believe this can be solved by

if ($PowerPlan -eq "High Performance") { $PowerPlan = "8C5E7FDA-E8BF-4A96-9A85-A6E23A8C635C" }

potatoqualitee avatar Jun 14 '21 10:06 potatoqualitee

We already set the powerplan based on the Guid (see #6679 for all the details - I was involved but forgot about it). I had a look at Get-DbaPowerPlan, Test-DbaPowerPlan and Set-DbaPowerPlan - and I would like to implement some changes to reduce duplicate code. Get-DbaPowerPlan is getting all powerplans from the computer but returning only the active. So Test-DbaPowerPlan needs to get all the plans again because it needs not just the active one but the best practise one as well. So in the first place I would like to add a new output parameter to Get-DbaPowerPlan to also return an array with all other powerplans on the computer. Then we can use this in Test-DbaPowerPlan and Set-DbaPowerPlan without having to most part of Get-DbaPowerPlan again. What do you think?

andreasjordan avatar Jun 14 '21 10:06 andreasjordan

Sounds good! -All or -List works for me. List is used by Get-ExecutionPolicy but All works too.

potatoqualitee avatar Jun 22 '21 11:06 potatoqualitee