Get and Set powerplan on Windows Hyper-v 2012 R2 Core

In my work on Hyper-V i have been looking at the performance of the hosts and wanted to both check and also be able to set the powerplan. In this post from Scripting Guys, Ed explains how to use CIM for the action to get and set the Power plans and how much faster that is than using WMI.

I have since Windows Server 2008 R2 tried to have the Core version as a best practice when running Hyper-V and in some cases it requires some extra skills and arguments during deployment and management 😉

The interesting part is that it differs between the full version and core as you can see that when I try to use Get-Cim from a Windows 2012 R2 full it works and I can see the different powerplans and also which one is active:

Screen Shot 2014-12-02 at 11.15.25

but when I try in a Windows Server 2012 R2 Core I get the following error “Provider load failure”, I have tried locally on the core and also remote so no difference there. My knowledge about WMI is a bit limited but a quick search says that it might be some missing or  corrupt files but I have tried 3 different servers installed with core so I would say it is something with missing!

Screen Shot 2014-12-02 at 11.33.01

As I want to be able to both check and set the right power plan centrally I have created two PowerShell functions that utilize the Powercfg.exe command within a invoke-command thus this works in Windows Server 2012 R2 Core. I am using regex for getting the active plan and the guid. The Set-PowerPlan can either use switch arguments or an actual Guid.

Screen Shot 2014-12-02 at 20.26.42

My friend and fellow Hyper-V MVP Didier WorkingHardInIT has made a blog post about live migration and why using “High performance”.

If you have any input or ideas how this could be improved or if you got it to work in core with CIM 🙂

Update 20150108

There is a workaround for this, PowerShell MVP Alexandar Nikolic gave me the link to the connect site which shows the following way to get it to work natively in core by copying the missing files:

# Either copy missing files
dir c:\windows\winsxs -inc wcl.dll,slr100.dll,wclpowrprof.dll -rec -EA 0 |
copy -Dest C:\windows\system32 -verbose

# see http://p0w3rsh3ll.wordpress.com/2014/12/28/fixing-a-wmi-provider-load-failure

Comments

Claes Abrahamsson
Reply

An even easier way of setting the power scheme to High Performance is:
Powercfg -SETACTIVE SCHEME_MIN

Leave a comment

name*

email* (not published)

website