Automation · Hyper-V Automation
VM Creation
Cheat sheet · https://pcornel.dk/topic.php?topic=5711
Answer
Hyper-V VM creation automation uses New-VM with -Generation 2, memory, VHDX path and switch, then Set-VMProcessor, Set-VMMemory and Add-VMDvdDrive or a template disk to build VMs consistently.
Remember
- Use Generation 2 for modern OSes.
- Set memory, CPU, disk and switch.
- Template disks speed deployment.
First checks
New-VM -Name <n> -Generation 2 -MemoryStartupBytes 4GB -SwitchName <sw> -NewVHDPath <p> -NewVHDSizeBytes 60GB— createAdd-ClusterVirtualMachineRole -VMName <n>— make HAStart-VM <n>— start
Verify in this order
parameters → New-VM → configure → cluster role → start
Where it usually breaks
Input/desired state → request accepted → job/task terminal status → target object read-back → effective runtime state → original workload → regression/rollback readiness.
Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5711