Automation · Hyper-V Automation
VM Hardware
Cheat sheet · https://pcornel.dk/topic.php?topic=5712
Answer
Hyper-V VM hardware automation changes CPU, memory, disks, NICs, Secure Boot and TPM with Set-VMProcessor, Set-VMMemory, Add-VMNetworkAdapter, Set-VMFirmware and Enable-VMTPM.
Remember
- Some hardware changes need the VM turned off.
- Secure Boot template must match the guest OS.
- A vTPM needs a key protector.
First checks
Set-VMProcessor <vm> -Count 4— vCPUSet-VMMemory <vm> -DynamicMemoryEnabled $false -StartupBytes 8GB— memoryGet-VM <vm> | Get-VMNetworkAdapter,Get-VMHardDiskDrive— devices
Verify in this order
desired hardware → Set-VM* → verify
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=5712