wbadmin - Recovering a vhdx file without overwritting the host VM

I need to restore a vhdx file from backup on a Windows 2019 Hyper-V Core server using the command line. This is the command I am using:

wbadmin start recovery -version:10/12/2021-05:00 -itemType:hyperV -items:F3D...1E -recoveryTarget:C:\temp

The command generates the following warnings. After which I am prompted to continue with the restore or cancel it.

Warning: If a Virtual Machine you are trying to recover to alternate location was backed up from this host, this will delete and overwrite the original virtual machine if it still exists.

You have chosen to recover the application HyperV. The files for the following components will be recovered to C:\temp. Note: Recovering the files to an alternate location without involving writer will not recover the application.

Warning: The virtual machines might not start if their network settings are different after recovery. After recovery is complete use Hyper-V Manager to verify the network settings of the virtual machines before they are started.

I do not want the restore operation to delete and overwrite the original VM as it states in the warning. Further the warning seems to be contradictory. The scenario I would like to have play out is written in the Note as I am assuming that "...without involving the writer the application will not recover the application" possibly means that wbadmin will despite its warning, not overwrite the VM on the host. I cannot find any information on this online.

Furthermore there is an [-alternateLocation] option to the wbadmin start recovery command that is poorly documented. It does not even seem to be included in the official Microsoft documentation online.

-alternateLocation  Valid only when recovering HyperV to alternate recovery target.
                    Allows recovering the HyperV components, updating configuration and
                    registering the VM with the Hyper-V management service.

Using it slightly changes the warnings I get, namely the Note is ommitted.

Warning: If a Virtual Machine you are trying to recover to alternate location was backed up from this host, this will delete and overwrite the original virtual machine if it still exists.

You have chosen to recover the application HyperV. The files for the following components will be recovered to C:\temp.

Warning: If a Virtual Machine you are trying to recover to alternate location was backed up from this host, this will delete and overwrite the original virtual machine if it still exists.

Warning: The virtual machines might not start if their network settings are different after recovery. After recovery is complete use Hyper-V Manager to verify the network settings of the virtual machines before they are started.

What I want to achive is basicaly a "Copy To File" as is found in the GUI version (Windows Server Backup) and I suspect the way to achieve this is by omitting the [-alternateLocation] option. I would like to see if anyone can confirm this before I pull the trigger and shoot myself in the foot. BTW I'm talking about an in production domain controller VM. So I cannot take any chances.


Since you're just looking to recover a file from the backup consider mounting the backup VHDX read-only and just copying the file your need from the backup. Mounting a specific version can be a little more involved than just mounting the last backup since you'll need to expose the snapshot first.

  • Do a wbadmin show versions and locate the GUID of the "Snapshot ID" you need to expose. I'd recommend placing this on your clipboard.

  • Run diskshadow and at the DISKSHADOW> prompt enter expose {Snapshot ID} x: where "x:" is the drive letter you'd like to expose the snapshot under. The clipboard comes in handy here. I will typically leave diskshadow running and continue with the process (because it's needed later).

  • Use your favorite method to mount the backup VHDX from the drive letter where you exposed the shadow. I will typically use Powershell and do something like $x = Mount-VHD -Path <<VHDX PATH>> -ReadOnly -Passthru so I have the mount details saved in a variable for later.

  • You can make sure the newly-mounted volume wasn't assigned a drive letter automatically in Powershell (assuming you mounted the disk as I did above) with $z = Get-Disk -Number $x.Number | Get-Partiton | Get-Volume and a $z to see what was returned.

  • You may want to assign the volume a drive letter. I find that frustrating with pure Powershell so I end up doing something like mountvol r: $z.UniqueId where "r:" is the drive letter I want to assign to the mounted backup VHDX.

  • Finally, having exposed the snapshot and mounted the backup VHDX you can access the volume via the drive letter you assigned and copy the file you need.

  • To tear all of this back down I would do mountvol r: /r to remove the drive letter from the mounted backup VHDX. I would dismount the VHDX using $x | Dismount-VHD. Finally, I'd flip back to diskshadow and do an UNEXPOSE X: to unexpose the snapshot. That puts the machine back in the state I found it.