VM Extras

In this section, we’ll outline a number of optional parameters you can use to modify for your VM.

Automatic Start

The following command controls how the hypervisor will handle starting the VM upon boot up.

Set-VM -VMName VMNAME -AutomaticStartAction Nothing

Below are valid values and their described function.

Value Description
Start Start the VM normally.
StartIfRunning Start the VM only if the VM was running when the hypervisor was shutdown.
Nothing Remain off, do not start the VM.

Automatic Stop

The following command controls how the hypervisor will handle stopping a VM when requested to shutdown.

Set-VM -VMName VMNAME -AutomaticStopAction Nothing

Below are valid values and their described function.

Value Description Equivalency
TurnOff Perform a hard shutdown of the VM. To holding the power off button on a physical server.
Save Save the VM’s state and shutdown. To putting the VM to sleep.
Shutdown Gracefully shutdown the VM. To shutting down a physical server normally via the start menu.

DVD Drive

The following command will attach and mount an ISO. Useful for installing operating systems.

# Local Path
Add-VMDvdDrive -VMName VMNAME -Path C:\Users\username\Downloads\installation_disk.iso

# Network Path
Add-VMDvdDrive -VMName VMNAME -Path \\SERVER\SHARE\installation_disk.iso

Boot Order

The following commands will determine and set the DVD drive to be the first boot device.

$vmDVDDrive = Get-VMDvdDrive -VMName VMNAME
Set-Firmware -VMName VMNAME -FirstBootDevice $vmDVDDrive

The following commands will determine and set the network adapter to be boot from first on startup.

⚠️
These commands only work if your VM has a single network adapter.
$vmNetworkAdapter = Get-VMNetworkAdapter -VMName VMNAME
Set-VMFirmware -VMName VMNAME -FirstBootDevice $vmNetworkAdapter

Enabling/Disabling Integrated Services

ℹ️
For more information on Hyper-V’s Integrated Services, please see Ram Prasad’s great technical write-up.

An integrated service can be disabled using the Disabled-VMIntegrationService command:

Disable-VMIntegrationService -VMName VMNAME -Name "Time Synchronization"

Enabling a integrated service can be completed through its counterpart command:

Enable-VMIntegrationService -VMName VMNAME -Name "Time Synchronization"

See Microsoft’s Docs for a list of available integrated services.