Pcornel
Automation

Hyper-V Automation

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

Back to the Topic

Answer

Hyper-V automation creates and manages VMs, virtual switches, disks, checkpoints, replication and clusters with the Hyper-V PowerShell module, often remotely across many hosts.

Remember

  • Most cmdlets support -ComputerName for remote hosts.
  • Remote management needs the right delegation.
  • Checkpoints are not backups.

First checks

  • Get-Command -Module Hyper-V | measure — cmdlets
  • Get-VM -ComputerName <host> — remote management
  • Invoke-Command -ComputerName <hosts> { Get-VMHost } — fleet

Verify in this order

script → Hyper-V module → hosts/VMs

Where it usually breaks

Automation/controller success is not target-state proof; target config/state is not effective-runtime proof; effective state is not workload proof.

→ Hyper-V Automation · operational reference

LayerHyper-V Automation operational reference
Runtime/ownershipHyper-V / Windows PowerShell current · identify controller/worker/target ownership before mutation
Persistent intentVersioned configuration/playbook/workflow with explicit dependencies and least-privilege identity
VerificationGet-VM / Select-Object Name,Id,State,Status,Version; Get-VMSwitch; Get-VMHost
Expected interpretationThe intended host/VM/switch identity is explicit, the mutation result is read back from Hyper-V, and guest/service readiness is checked separately when relevant.
Recovery boundaryPreserve correlation IDs + pre-state, then verify target/service independently after remediation

Read-only verification commands unless stated otherwise. Confirm syntax for your platform and release. Full reference: https://pcornel.dk/topic.php?topic=5708

Confirmation

Confirm action

Continue?