VMHyperV: Support AutomaticStartAction and AutomaticStopAction
Resource proposal
I suggest adding support for configuring AutomaticStartAction and AutomaticStopAction, which can be configured using Set-VM:
Set-VM -Name $VmName -AutomaticStartAction Start/StartIfRunning/Nothing -AutomaticStopAction Save/TurnOff/ShutDown
Proposed properties
| Property | Data type | Description | Default value | Allowed values |
|---|---|---|---|---|
| AutomaticStartAction | String | Configures automatic start action for VM | None | Start/StartIfRunning/Nothing |
| AutomaticStopAction | String | Configures automatic stop action for VM | None | Save/TurnOff/ShutDown |
Special considerations or limitations
Modifying these properties can only be done when the VM is powered off
So if these properties can only be modified when the VM is off, should they only be allowed to be configured when the VM is created, or should these also be enforced if they diverge? If the later how should there be an opt-in for turning off and on a VM to be able to enforce these values?
Good question.
I was just looking at how this works for the ProcessorCount property, and noticed it will turn off the VM when the value changes if RestartIfNeeded is set to true. Otherwise, it fails with the following error:
PowerShell DSC resource DSC_VMHyperV failed to execute Set-TargetResource functionality with error message: System.InvalidOperationException: Can not change
properties for VM 'Disk1_vm' in 'Running' state unless 'RestartIfNeeded' is set to true.
I think AutomaticStartAction/AutomaticStopAction should follow the same pattern.
Great, that will do.