Modify Automatic Stop Action for Hyper-V Virtual Machines on Windows 11

Modify Automatic Stop Action for Hyper-V Virtual Machines on Windows 11

Hyper-V is a Microsoft proprietary Hypervisor tool that enables the creation and management of virtual machines. By default, when a virtual machine (VM) is shut down, its state is saved; however, this behavior can be modified. In this article, we will explore how to change the automatic stop action of a Hyper-V Virtual Machine.

Change Automatic Stop Action of Hyper-V Virtual Machine

Hyper-V is configured to automatically save the state of virtual machines when the host is shut down or restarted. This means that any running virtual machines will automatically resume upon the next start. This setting can be customized for each VM.

There are three options to manage the automatic stop action of a virtual machine:

  1. Save the virtual machine state: This option reserves disk space equal to the memory used by the VM when it’s active, allowing the memory to be stored on disk during host shutdown or restart. The VM will start automatically on the next boot and resume from the saved state.
  2. Turn off the virtual machine: This option forces an immediate shutdown of the VM without saving any state information. The guest operating system will initiate as if it lost power.
  3. Shut down the guest operating system: This option ensures that the guest operating system is gracefully shut down prior to the host powering off or rebooting. While no state is retained, the downside is that the guest operating system and its services may take longer to initiate when the host restarts. When selecting this option, it is essential to consider the sequencing and potential delay of VM startups.

To change the automatic stop action of the Hyper-V Virtual Machine, you must have administrative privileges. If you have the necessary permissions, you can use one of the methods outlined below.

Change Automatic Stop Action using Hyper-V Manager

Change Automatic Stop Action of Hyper-V Virtual Machine

The simplest method is to adjust the settings through Hyper-V Manager. Follow these steps:

  1. Launch Hyper-V Manager from the Start Menu.
  2. Right-click on the virtual machine you wish to configure and select Settings.
  3. Adjust the state to Save the virtual machine state, Turn off the virtual machine, or Shut down the guest operating system by selecting the corresponding option and then clicking OK.

After making the changes, start your virtual machine, and it will stop according to the newly assigned state when shut down.

Change Automatic Stop Action using PowerShell

You can also modify the stop action using Windows PowerShell. To do this, open PowerShell with administrator rights.

First, identify the name of your existing virtual machine by executing the command Get-VM.

To set the state to “Save the virtual machine state,” use the following command:

Set-VM -Name "VMName"-AutomaticStopAction Save

To change the state to “Turn off the virtual machine,” execute:

Set-VM -Name "VMName"-AutomaticStopAction TurnOff​

To switch to the “Shut down the guest operating system” state, run:

Set-VM -Name "VMName"-AutomaticStopAction ShutDown​

Be sure to replace VMName with the actual name of your virtual machine.

To verify the current automatic stop action of the virtual machine, you can run this command:

Get-VM -VMName * | Select-Object VMName, AutomaticStartAction, AutomaticStartDelay, AutomaticStopAction

This command will display your current Automatic Stop Action along with any Automatic Start Action set.

How do I stop Hyper-V from automatically starting?

To prevent Hyper-V from automatically starting, you need to adjust the Automatic Start State. Right-click on your virtual machine in Hyper-V Manager, navigate to Automatic Start State, and choose Nothing or Automatically start delay, then set a Startup delay time.

What is the automatic start and stop action for a virtual machine?

Automatic Start Action determines whether a VM starts automatically when the host is powered up. It has three options: do nothing, start if it was running previously, and delay start. Conversely, Automatic Stop Action dictates the behavior of VMs at host shutdown, providing three options: Save state, Turn off, and Shut down the guest operating system.

Source

Leave a Reply

Your email address will not be published. Required fields are marked *