How to Perform Test Failovers on Hyper-V Virtual Machines in Windows 11 Using PowerShell

In enterprise disaster recovery (DR) planning, regularly validating business continuity readiness is mandatory for regulatory compliance and operational resilience. However, testing failovers on production workloads traditionally risked service interruption, network conflicts (such as duplicate IP addresses and NetBIOS collisions), and broken replication synchronization. Under Microsoft Hyper-V, administrators can execute risk-free, non-disruptive disaster recovery simulations using Hyper-V Test Failover. Available in Windows 11 and Windows Server Hyper-V environments, the Start-VMFailover and Stop-VMFailover PowerShell cmdlets allow administrators to instantiate isolated replica sandboxes, verify guest application integrity, and clean up test resources without interrupting ongoing production replication.

Understanding Hyper-V Test Failover Architecture

Hyper-V Replica separates failover actions into three distinct operational modes:

  • Planned Failover: An intentional, zero-data-loss failover where the primary VM is gracefully shut down, remaining delta changes are replicated to the replica host, and the replica VM starts in production mode.
  • Unplanned Failover: An emergency failover initiated when the primary host experiences unexpected catastrophic failure, starting the replica VM from the latest available recovery point with potential minor data loss.
  • Test Failover (Non-Disruptive): The replica host takes a differential snapshot of the replica VHDX disk and instantiates a temporary, synthetic virtual machine (appended with - Test in its display name). The primary VM remains active, delta replication continues transferring data in the background, and no network collisions occur when attached to an isolated test switch.

Configuring an Isolated Test Virtual Switch

Before initiating a test failover, best practice requires creating an internal or private virtual switch. This guarantees that when the test VM boots, it cannot communicate with the active production primary VM or external network endpoints, preventing IP address conflicts and database split-brain conditions:

# Open elevated PowerShell console on Replica Host
# Create a dedicated private switch for DR testing
New-VMSwitch -Name "DR-Test-IsolatedSwitch" -SwitchType Private

Configuring Test Failover Network Settings

Hyper-V Replica allows administrators to pre-define which virtual switch and network settings the test VM binds to upon test instantiation, eliminating manual intervention during emergency drills:

# Pre-bind the replica virtual machine to the isolated test switch
Set-VMNetworkAdapter -VMName "AppServer-01" `
  -SwitchName "DR-Test-IsolatedSwitch" `
  -TestNetworkAdapter

Inspecting Available Recovery Points

Hyper-V Replica maintains recovery points based on the replication policy configured on the primary host. You can inspect available historical checkpoints to decide which point in time to test:

Get-VMSnapshot -VMName "AppServer-01" -SnapshotType RecoveryPoint

This command returns timestamped recovery points. If no specific recovery point is specified during failover, Hyper-V defaults to using the latest synchronized state.

Initiating a Non-Disruptive Test Failover with Start-VMFailover

To initiate the test failover on the replica host, execute the Start-VMFailover cmdlet with the -AsTest switch:

# Initiate test failover using latest recovery point
Start-VMFailover -VMName "AppServer-01" -AsTest

Hyper-V instantly instantiates a new virtual machine named AppServer-01 - Test. Verify the state of the newly created test machine:

Get-VM | Where-Object { $_.Name -like "*- Test" }

Starting the Test Virtual Machine

Once created, power on the test virtual machine to begin disaster recovery validation:

Start-VM -Name "AppServer-01 - Test"

The test VM boots from the isolated recovery checkpoint. Because it is connected to DR-Test-IsolatedSwitch, administrators can log in via Hyper-V Virtual Machine Connection (VMConnect) or PowerShell Direct, start line-of-business services, and verify database consistency.

Validating Ongoing Replication Integrity

While the test virtual machine is running, verify that standard replication from the primary host remains unimpaired:

# Query replication health on the primary or replica host
Get-VMReplication -VMName "AppServer-01" | Select-Object Name, ReplicationHealth, ReplicationState, CurrentReplicaServerName

The ReplicationState continues reporting Replicating, proving that ongoing delta log shipping remains active and uninterrupted.

Terminating the Test and Cleaning Up Resources

After disaster recovery validation concludes, stop the test VM and execute Stop-VMFailover with the -AsTest parameter:

# Stop the test virtual machine
Stop-VM -Name "AppServer-01 - Test" -Force

# Stop test failover and automatically dismantle temporary test VM and differential disks
Stop-VMFailover -VMName "AppServer-01" -AsTest

Hyper-V automatically deletes the AppServer-01 - Test virtual machine, removes the temporary differencing VHDX disk, and merges recovery state cleanly without manual disk management.

By leveraging PowerShell’s Start-VMFailover -AsTest and Stop-VMFailover -AsTest cmdlets, virtualization engineers can conduct deterministic, non-disruptive disaster recovery testing, ensuring verified business continuity while safeguarding live production workloads.

Get the best tech tips delivered straight to your inbox.

Join thousands of readers mastering Apple, Google, Microsoft, and Linux.