You dont have javascript enabled! Please enable it!

HyperV Prevented Starting Virtual Machine Because it is Prepared For Failover #AzureSiteRecovery #ASR

3 Min. Read

Hello folks,

I was recently cleaning my Azure Site Recovery failover demo at the Azure ITCamp and I hit the following error:

An error occurred while attempting to start the selected virtual machine. Hyper-V prevented starting virtual machine because it is prepared for planned failover. Virtual machine can be started after cancelling failover preparation”.


Now before I start with the root cause and the solution of this error, here is what my demo looks like:

  • Single Hyper-V host registered with Azure Site Recovery Vault.
  • Single Hyper-V site to group one or more Hyper-V servers located in a physical location.
  • Single Protection group to group together virtual machines that have common protection requirements.
  • Two tier application (VMs) protected with ASR (Back-end SQL database and front-end web server).
  • Single Recovery Plan to shutdown and startup virtual machines in sequence as the following: (Shutdown: 1- Web Server / 2-SQL DB – Startup: 1-SQL DB / 2- Web Server).

During my demo, I initiated a planned failover which took around 34 minutes…

If you want to know what Azure Site Recovery does behind the scene, here is the job details:


As you can see, the planned failover completed successfully!

During the planned failover process, I lost network connectivity between my Hyper-V site and Azure, what I ended up with a Virtual Machine on-premises with “Prepared for planned failover”.



The virtual machines are in off state, because Azure Site Recovery during the planned failover operation will initiate a final synch before shutting down the VMs on-premise.

If you are familiar with Hyper-V Replica technology, ASR use the same technology.

During the cleaning process, I started deleting the virtual machines and Hyper-V server from the Azure Site Recovery portal without paying attention on the status on–premise, this causes the VM not to start because it’s still in prepared for failover state, however the failover to Azure was completed.


There is no option to remove the replication for this VM from Hyper-V Manager, because when a VM is protected using ASR, all the operations must be done from the Azure Site Recovery portal and not from Hyper-V Manager.

What about PowerShell…


The error is a little bit different here… The operation not allowed because the virtual machine is replicating to a provider other Hyper-V.

Who is the other provider? … ASR of course… The UI error was more precise in this case.

Now in order to manual unregister the Hyper-V server and disable the protection, you want to run the following script on the Hyper-V server where the VM reside.

pushd .
     $principal=new-object System.Security.Principal.WindowsPrincipal($windowsIdentity)
     if (!$isAdmin)
        "Please run the script as an administrator in elevated mode."
        $choice = Read-Host

    "This script will remove the old Azure Site Recovery Provider related properties. Do you want to continue (Y/N) ?"
    $choice =  Read-Host

    if (!($choice -eq 'Y' -or $choice -eq 'y'))
    "Stopping cleanup."

    $serviceName = "dra"
    $service = Get-Service -Name $serviceName
    if ($service.Status -eq "Running")
        "Stopping the Azure Site Recovery service..."
        net stop $serviceName

    $asrHivePath = "HKLM:\SOFTWARE\Microsoft\Azure Site Recovery"
    $registrationPath = $asrHivePath + '\Registration'
    $proxySettingsPath = $asrHivePath + '\ProxySettings'
    $draIdvalue = 'DraID'

    if (Test-Path $asrHivePath)
        if (Test-Path $registrationPath)
            "Removing registration related registry keys."  
            Remove-Item -Recurse -Path $registrationPath

        if (Test-Path $proxySettingsPath)
            "Removing proxy settings"
            Remove-Item -Recurse -Path $proxySettingsPath

        $regNode = Get-ItemProperty -Path $asrHivePath
        if($regNode.DraID -ne $null)
            "Removing DraId"
            Remove-ItemProperty -Path $asrHivePath -Name $draIdValue
        "Registry keys removed."

    # First retrive all the certificates to be deleted
    $ASRcerts = Get-ChildItem -Path cert:\localmachine\my | where-object {$_.friendlyname.startswith('ASR_SRSAUTH_CERT_KEY_CONTAINER') -or $_.friendlyname.startswith('ASR_HYPER_V_HOST_CERT_KEY_CONTAINER')}
    # Open a cert store object
    $store = New-Object System.Security.Cryptography.X509Certificates.X509Store("My","LocalMachine")
    # Delete the certs
    "Removing all related certificates"
    foreach ($cert in $ASRcerts)
    Write-Host "Error occured" -ForegroundColor "Red"
    Write-Host "FAILED" -ForegroundColor "Red"


This script will remove the old Azure Site Recovery Provider and all related settings on the server.

After removing Azure Site Recovery Provider from the server, we need to clean up the protection settings for the VM manually.

On the source affected Hyper-V host server, to remove replication for the virtual machine use this script. Replace $vmName with the name of your virtual machine.

$vmName = "VM-T02"
$vm = Get-WmiObject -Namespace "root\virtualization\v2" -Query "Select * From Msvm_ComputerSystem Where ElementName = '$vmName'"
$replicationService = Get-WmiObject -Namespace "root\virtualization\v2"  -Query "Select * From Msvm_ReplicationService"


This script will remove the replication settings for the affected VM by querying the WMI Namespace “root\virtualization\v2“, then query the “Msvm_ReplicationService” class and remove the replication relationship.

The VM will start now and the replication is manually removed Smile


Reference: Azure Site Recovery Documentation.

Hope this helps!

Enjoy your weekend…


Photo of author
About the Author
Charbel Nemnom
Charbel Nemnom is a Senior Cloud Architect, Swiss Certified ICT Security Expert, Certified Cloud Security Professional (CCSP), Certified Information Security Manager (CISM), Microsoft Most Valuable Professional (MVP), and Microsoft Certified Trainer (MCT). He has over 20 years of broad IT experience serving on and guiding technical teams to optimize the performance of mission-critical enterprise systems with extensive practical knowledge of complex systems build, network design, business continuity, and cloud security.

Related Posts


Update Rollup 9 for System Center 2012 R2 is Now Available #SysCtr #SystemCenter #SCVMM

Free Whitepaper! Understand Microsoft Hyper-Converged Solution #WS2016 #HyperV #S2D


Let me know what you think, or ask a question...

error: Alert: The content of this website is copyrighted from being plagiarized! You can copy from the 'Code Blocks' in 'Black' by selecting the Code. Thank You!