Is power management supported for virtual machines running on Hyper-V?

Anonymous
2023-10-15T16:36:19.5033333+00:00

Hello

What I need is the guest virtual machine running on Hyper-V to be able to use power management features including hibernation.

For S1-S4 power management in Hyper-V virtual machines, but encountering an error when enabling hibernate using "powercfg /h on," which says, "The system firmware does not support."

System Center Virtual Machine Manager
Hyper-V
Hyper-V
A Windows technology providing a hypervisor-based virtualization solution enabling customers to consolidate workloads onto a single server.
2,738 questions
0 comments No comments
{count} votes

Accepted answer
  1. AlexZhu-MSFT 5,956 Reputation points Microsoft Vendor
    2023-10-16T02:51:22.7833333+00:00

    Hi,

    Please try the following to see if it works.

    1. Disable dynamic memory on the VM since it's incompatible with hibernation.
    2. Run the following PowerShell script on the host:
    
    Param (
        [string]$VmName,
        [bool]$Enable = $true
    )
    
    # To modify, machine must be off
    $Vm = Get-VM -Name $VmName
    $Vm | Stop-VM -Force -WarningAction Ignore
    
    $wmiComputerSystem = gwmi -namespace root\virtualization\v2 -query "select * from Msvm_ComputerSystem where ElementName= '$VmName'"
    $wmi_vsSettingData = $wmiComputerSystem.GetRelated("Msvm_VirtualSystemSettingData","Msvm_SettingsDefineState",$null,$null, "SettingData", "ManagedElement", $false, $null)
     
    Write-Output ("Before: EnableHibernation = " + $wmi_vsSettingData.EnableHibernation)
    
    # $wmi_vsSettingData.EnableHibernation = $Enable  # Doesn't work - says The property 'EnableHibernation' cannot be found on this object
    # So, need to munge XML ourselves
    [xml]$vsSettingsDataXml = $wmi_vsSettingData.gettext(1)
    $EnableHibernationNodes = $vsSettingsDataXml.SelectNodes("/INSTANCE/PROPERTY[@NAME='EnableHibernation']")
    $EnableHibernationNodes[0].VALUE=$Enable.ToString()
    
    $wmi_vsSettingDataMgmt = Get-WmiObject -Namespace "root\virtualization\v2" -Class Msvm_VirtualSystemManagementService
    $job = $wmi_vsSettingDataMgmt.ModifySystemSettings($vsSettingsDataXml.OuterXml)
    
    
    
    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.