Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Bug] Set-DbaPowerPlan fails on WS2019 #6505

Closed
1 of 5 tasks
comnam90 opened this issue Apr 29, 2020 · 2 comments · Fixed by #6679
Closed
1 of 5 tasks

[Bug] Set-DbaPowerPlan fails on WS2019 #6505

comnam90 opened this issue Apr 29, 2020 · 2 comments · Fixed by #6679
Labels

Comments

@comnam90
Copy link

Environmental information

#### 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:\Users\a-bent\Documents\WindowsPowerShell\Modules\dbatools\1.0.107\dbatools.psd1
Version : 1.0.107

LCID             Name             DisplayName
----             ----             -----------
5129             en-NZ            English (New Zealand)

Report

On Windows Server 2019, the Set-DbaPowerPlan command fails as it appears the 'Activate' Cim Method for Win32_PowerPlan appears to be broken.

This seems to be widely reported in other community projects:

Like other projects, it looks like the only option is to use the Windows APIs via powercfg.exe command.

Host used

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

If anything other than powershell.exe was used, please confirm that you can duplicate the issue with powershell.exe

  • Still buggy in powershell.exe

Errors Received

writeErrorStream      : True
PSMessageDetails      : 
Exception             : System.Exception: Couldn't set the requested Power Plan 'High Performance' on sqlserver.
TargetObject          : sqlserver
CategoryInfo          : ConnectionError: (sqlserver:PSObject) [Write-Error], Exception
FullyQualifiedErrorId : dbatools_Set-DbaPowerPlanInternal,Stop-Function
ErrorDetails          : Couldn't set the requested Power Plan 'High Performance' on sqlserver.
InvocationInfo        : System.Management.Automation.InvocationInfo
ScriptStackTrace      : at Stop-Function, C:\Users\username\Documents\WindowsPowerShell\Modules\dbatools\1.0.107\allcommands.ps1: line 82910
                        at Set-DbaPowerPlanInternal, C:\Users\username\Documents\WindowsPowerShell\Modules\dbatools\1.0.107\allcommands.ps1: line 65811
                        at Set-DbaPowerPlan<Process>, C:\Users\username\Documents\WindowsPowerShell\Modules\dbatools\1.0.107\allcommands.ps1: line 65849
                        at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo : {0, 1}

Steps to Reproduce

Run the Set-DbaPowerPlan command on a fresh deployment of Windows Server 2019

Set-DbaPowerPlan -ComputerName sqlserver

Expected Behavior

Windows Power Plan to be set to 'High Performance'

Actual Behavior

Error thrown and Power Plan failed to update.

@andreasjordan
Copy link
Contributor

I just ran into this problem and had a look at the links above.
ansible/ansible#43827 is really helpful if you have a look at the coresponding pull request ansible/ansible#51471 and there the file https://github.com/jborean93/ansible/blob/65a10d21d3ea6424f0d7b162c9b74853cb5b22dc/lib/ansible/modules/windows/win_power_plan.ps1
The code there seems to work (works on my lab with a windows server 2019) and could maybe adopted for dbatools.
@potatoqualitee : As I haved worked with Windows-DDLs and powershell yet - do you have commands in dbatools that allready use Windows-DLLs?

@wsmelton
Copy link
Member

We do not use any Windows DLLs currently.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants