Just wanted to drop a note about the “Root\CIMV2\power” part of WMI!
It appears as though if there is a power policy defined via group policy (or an application that implements local power policy through logal group policy), that the WMI inspectors targeting “Root\CIMV2\power” will return, “The expression could not be evaluated: Windows Error 0x800704ec: This program is blocked by group policy. For more information, contact your system administrator.”
Queries like:
selects "InstanceID from win32_powerplan where isActive=true" of wmi "Root\CIMV2\power"
This is of course an issue because we are trying to verify our current power policy
For future reference, the majority of the WMI information I was using is available directly from the registry though the resulting relevance is more complex. I have moved all of the C3 Power Management content for Windows over to utilizing registry inspectors instead of WMI inspectors and there are multiple examples of pulling settings here: https://github.com/strawgate/C3-Power-Management/blob/master/Analyses/Power%20-%20Configuration%20-%20Windows.bes
Note: The relevance is complex as it is because of how Windows defines custom power policies – trust me it’s not fun!
Using the properties in that analysis one should really be able to pull any piece of information regarding the Windows Power Policy.
I actually didn’t know about the WMI option until recently and have used the registry locations primarily. I guess it is a good thing I didn’t go down the WMI rabbit hole when I found it.
Yeah, it’s rather unfortunate that even though Microsoft spent years encouraging WMI for management tasks, every time there are at least two ways to do something, WMI is the wrong one.
It remains to be seen whether PowerShell is going to turn in to the same trap.
The ActivePowerScheme value in the registry will point to whatever the last power policy was but the actually active power scheme will be whatever is defined in group policy:
value "ActivePowerScheme" of keys "HKEY_LOCAL_MACHINE\Software\Policies\Microsoft\Power\PowerSettings" of native registry
To add to this, any other settings configured with an administrative template individually (not via a preference):
Will also appear under the “Policies\Microsoft\Power\PowerSettings” this key and will override whatever the other registry power configuration seem to indicate.