Pcornel
Automation · Hyper-V Automation

VM Hardware

Cheat sheet · https://pcornel.dk/topic.php?topic=5712

Back to the Topic

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 — vCPU
  • Set-VMMemory <vm> -DynamicMemoryEnabled $false -StartupBytes 8GB — memory
  • Get-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

Confirmation

Confirm action

Continue?