Pcornel
Browse topics
Options
Recent
Favorites
Automation · Technical reference

Hyper-V Automation

Direct 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.

When to use this

Use this when automating Hyper-V hosts, VMs, switches and clusters with PowerShell.

First 30 seconds

1. Hyper-V automation with the Hyper-V PowerShell module (and FailoverClusters).

2. Remote management via WinRM.

3. Idempotent scripts/DSC.

4. -WhatIf where supported.

5. Log changes.

Operational verification

script → Hyper-V module → hosts/VMs

Context & applicabilityCommon mistakes · platform/version boundaries
Platform / version applicability
Hyper-V / Windows PowerShell current
applies
Structured applicability is explicit Topic metadata; it does not infer compatibility beyond the stored rows.
At a glance

Operational reference

Fast context before you go deeper.

PlatformHyper-V / Windows PowerShell current · Automation implementations are tool and platform specific. Use the adjacent Domain for the technology being automated and this Domain for automation behavior.
Scope / prerequisiteUse this when automating Hyper-V hosts, VMs, switches and clusters with PowerShell.
What next?3 suggested next steps
Child topics (this level)11
Evidence1
On this pageJump to a specific section
Operational workflow

Verification & Troubleshooting

Start with the observed symptom, prove the nearest boundary, and move outward only when the current state is understood.

3 steps Observe → verify → isolate → change minimally → repeat the original test.
ObservedRecord what the original test actually shows

Capture the concrete output, symptom, packet, log or counter before changing anything.

Step 1 Target-state verification ladder Verify boundary

Hyper-V Automation uses a strict target-state ladder for Hyper-V management request to VM effective state: request accepted → job/task succeeded → target object changed → effective runtime state confirmed → original workload verified.

Step 2 Verification path Verify boundary

Begin by proving the management host/cluster and stable VM identity (Id) rather than matching only by display name. Capture current VM state, host/owner, generation/version, storage and network adapters relevant to the change. Execute one bounded operation, then re-run Hyper-V read-only commands until the expected hypervisor state is reached. If the objective depends on the guest, verify heartbeat/integration status and preferably query the guest/application through an independent management/service path. For networking changes, check both VM adapter attachment and the guest/service reachability expected by the change. Test permission and missing-resource failures so automation does not create a new VM/switch when lookup unexpectedly fails. Preserve before/after object properties and IDs.

Step 3 Where it fails Narrow the fault

Separate PowerShell/remoting, Hyper-V management service, host resources/storage/network, failover-cluster ownership, VM runtime and guest/application state. A remoting session can be healthy while VMMS rejects an operation; a VM can be Running while the guest is hung; a local host may not own a clustered VM; and a checkpoint operation can succeed while consuming unsafe storage capacity. Diagnose the first step whose expected state is absent instead of repeating the mutation. Be especially careful with retries around creation, checkpoint and move operations because duplicate objects or concurrent ownership changes may occur. Preserve stable IDs and cluster/host context before recovery. Re-run both Hyper-V and consumer-facing verification after remediation.

Evidence references

Evidence · 1 on this Topic

Expected observations and documentation recipes are reference material. Record actual output, device identity, scope and time before claiming a verified result.

observation · 1
Drill down

Subtopics

Go one level deeper into this subject.

Subtopic Hyper-V PowerShell

The Hyper-V PowerShell module provides cmdlets like New-VM, Get-VM, Set-VM, Start-VM and Move-VM for managing VMs locally or with -ComputerName on remote hosts.

Subtopic Host Configuration

Hyper-V host configuration automation sets up hosts with Install-WindowsFeature Hyper-V, Set-VMHost for default paths and migration settings, NUMA spanning and live migration networks.

Subtopic VM Creation

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.

Subtopic VM Hardware

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.

Subtopic Virtual Switches

Hyper-V virtual switch automation creates external, internal and private switches with New-VMSwitch, including Switch Embedded Teaming, and sets VLANs with Set-VMNetworkAdapterVlan.

Subtopic VHDX

VHDX automation creates and changes virtual disks with New-VHD, Resize-VHD, Convert-VHD, Mount-VHD and Optimize-VHD, and attaches them with Add-VMHardDiskDrive.

Subtopic Checkpoints

Hyper-V checkpoint automation creates, lists, applies and removes checkpoints with Checkpoint-VM, Get-VMSnapshot, Restore-VMSnapshot and Remove-VMSnapshot, cleaning up old ones so AVHDX chains do not grow.

Subtopic Migration

Hyper-V migration automation moves VMs between hosts with Move-VM, including storage with -IncludeStorage, and checks compatibility first with Compare-VM.

Subtopic Replication

Hyper-V replication automation configures Hyper-V Replica with Enable-VMReplication, Start-VMInitialReplication and Start-VMFailover, replicating VMs to a second host or site.

Subtopic Cluster Automation

Hyper-V cluster automation manages failover clusters with the FailoverClusters module — Add-ClusterVirtualMachineRole, Move-ClusterVirtualMachineRole, Cluster-Aware Updating and CSV operations.

Subtopic Hyper-V Automation Troubleshooting

Troubleshoot Hyper-V automation by checking the module is loaded and the account is in Hyper-V Administrators, remoting and CredSSP or Kerberos delegation for remote hosts, and Hyper-V-VMMS event logs.

Key points
  • Most cmdlets support -ComputerName for remote hosts.
  • Remote management needs the right delegation.
  • Checkpoints are not backups.
Key checks
  • Get-Command -Module Hyper-V | measure — cmdlets
  • Get-VM -ComputerName <host> — remote management
  • Invoke-Command -ComputerName <hosts> { Get-VMHost } — fleet
ReferenceWhy it matters1 section · depth on demand

In depth

Hyper-V automation uses the Hyper-V PowerShell module (and Failover Clustering cmdlets) to create VMs, virtual switches, disks and checkpoints, and to configure hosts — locally, over remoting, or through SCVMM or Ansible.

New-VM -Name web03 -Generation 2 -MemoryStartupBytes 4GB -NewVHDPath D:\VMs\web03.vhdx -NewVHDSizeBytes 60GB -SwitchName vSwitch-LAN
Set-VMProcessor web03 -Count 2
Set-VMFirmware web03 -EnableSecureBoot On -SecureBootTemplate MicrosoftUEFICertificateAuthority
Start-VM web03

The Linux Secure Boot template (MicrosoftUEFICertificateAuthority) is needed for most Linux guests.

ReferenceImportant terms & boundaries1 section · depth on demand

Mechanics

Hyper-V Automation typically drives the Hyper-V PowerShell module/WMI/CIM management layer against a host or cluster. Host identity, VM GUID, generation, configuration version, storage paths, virtual switches and cluster ownership determine what an operation actually affects. VM lifecycle commands can be asynchronous from the perspective of guest readiness, and a VM state of Running only shows the hypervisor launched it—not that the guest OS or application is healthy. Checkpoints capture VM state according to checkpoint type and are not equivalent to application-consistent backup. Clustered VMs add ownership/failover boundaries that local host commands may not fully represent. Safe automation therefore resolves stable VM IDs and current owner/host before mutation and verifies both Hyper-V state and any required guest/service state.

Source basisSource attribution states what this section is based on; it is not independent proof that the current environment matches it.
ReferenceConfiguration & state1 section · depth on demand

Lifecycle

Version scripts/modules and declare the Windows/Hyper-V versions they support. Use least-privilege management identities and constrained remoting/JEA where appropriate rather than broad local administrator reuse. Keep VM placement, storage, network/switch and checkpoint policy in reviewed configuration; do not derive critical paths from whichever host happens to run the script. Coordinate with Failover Clustering for clustered workloads and define maintenance/migration behavior before host patching. Checkpoint creation/retention needs explicit cleanup and storage-capacity policy. For provisioning, generate unique identities and validate switch/storage existence before New-VM. Track guest integration services and automation dependencies separately from hypervisor management. Recovery procedures should identify when to restore configuration, disks, checkpoints or application backups.

Additional reference context Scope · expected state · examples · history · terminology Open only when you need the supporting context
Technical verification history

Verification history & basis

When and against what this Topic was checked. Later text edits do not count as a new check.

2026-09-14 · vendor docHyper-V / Windows PowerShell current Windows Server 2025/current

Authoritative/upstream documentation reviewed for bounded claims in > Hyper-V Automation. Documentation verification only; this is not observed lab or production Evidence.

Basis: https://learn.microsoft.com/en-us/windows-server/virtualization/hyper-v/powershell · confidence 94%
Technical changelog & impact

What changed and what may be affected

Recent technical edits are separated from ordinary page timestamps. Relationship impact is advisory: it identifies nearby canonical references to review, not automatic breakage.

Related reference impactReview these references after material technical changes when their shared boundary is affected.
Embedded reference data

Quick lookup tables

→ Hyper-V Automation · operational reference

Context-specific ownership, verification, output and failure-boundary lookup for → Hyper-V Automation.

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
Depth when you need it

Deep reference

Healthy vs suspicious evidence

Output interpretation

Prefer PowerShell objects with selected stable properties over formatted Get-VM tables. Preserve VM Id, host/cluster owner, state/status, adapter/switch IDs, disk paths, checkpoint IDs and operation timestamps. $?/PowerShell completion is not enough; cmdlets can complete while a later asynchronous state transition fails. For remote sessions, serialization can change object behavior, so treat returned data as evidence rather than a live management object outside its session. Separate hypervisor operation result from guest heartbeat and application/service verification. For fan-out host maintenance, keep per-VM/per-host outcomes. Logs should never expose credentials and should make it possible to identify exactly which VM/resource was mutated if names are duplicated across environments.

Confirmation

Confirm action

Continue?