Automation
Hyper-V Automation
Cheat sheet · https://pcornel.dk/topic.php?topic=5708
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— cmdletsGet-VM -ComputerName <host>— remote managementInvoke-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
| Layer | Hyper-V Automation operational reference |
|---|---|
| Runtime/ownership | Hyper-V / Windows PowerShell current · identify controller/worker/target ownership before mutation |
| Persistent intent | Versioned configuration/playbook/workflow with explicit dependencies and least-privilege identity |
| Verification | Get-VM / Select-Object Name,Id,State,Status,Version; Get-VMSwitch; Get-VMHost |
| Expected interpretation | The 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 boundary | Preserve 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