Cry about...
MS-Windows Troubleshooting
Hyper-V Manager: Virtual machines have disappeared after a Windows feature update
Symptom:
Virtual machines that existed on the machine are no longer visible under Hyper-V manager after a Windows feature update.
All the files for the hyper-v virtual machines are still present on the drive. They just do not show up in Hyper-V and are not started.
The same problem might possibly exist after other Windows updates, but I encountered it after a Windows "feature" update.
Possible Causes and Remedies:
The Windows feature update makes the assumption that the virtual machines are located in the default location. So when the feature update updates the symbolic link for each virtual machine it changes the location - breaking it for any virtual machines that are not in the default location, such as for all those that are located on a different drive.
How to test this is the case?
Using Windows Explorer navigate to:
C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines
Remember that C:\ProgramData
is a hidden folder. So it isn't normally visible but that shouldn't stop you from typing the folder into the address bar.
There will be one symbolic link visible for each virtual machine. Each symbolic link is to the configuration file for virtual machine which is why it looks like a GUID and not the virtual machine name.
Try right clicking on each of those in turn and select "Edit". It should open straight away into notepad - showing XML. If it does than the symbolic link is good and that isn't the problem.
If Windows pops up a dialog saying:
Missing Shutcut
Windows is searching for ...
and then after a few moments instead shows a larger dialog:
Problem with Shortcut
The item '... .xml' that this shortcut refers to has been changed or moved, so this shortcut will no longer work properly.
Then you know the symbolic link is broken. If Windows offers a "nearest match" then ignore that, don't select to [Fix it] or [Delete it] just select [Cancel].
How to repair the symbolic link
I haven't been able to find a way of repairing the symbolic link, but you can replace it:
- Locate the XML file with the same name. This will be in the "Virtual Machines" folder.
Where that folder is will depend on how you have organised your virtual machines on disk. Typically this will be under something like:
drive:\some-path\Hyper-V\Virtual Machines
or
drive:\some-path\Hyper-V\machine-name\Virtual Machines
Remember that the name of the XML file will be the same as that of the bad shortcut file.
- In Hyper-v Manager right click on the machine name and select "Stop Service". At the prompt that comes ("Are you sure you want to stop the Virtual Machine Management service ...") select [Turn Off].
- Rename the shortcut adding ".bad" to the name. It is useful to have the original name visible, which is why I don't initially delete the shortcut.
- Recreate the symbolic link. You can either use PowerShell for this or an elevanted command prompt:
Using an elevated command prompt:
- Open an elevated command prompt window.
- CD to the folder containing the shortcuts:
cd "C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines"
- Use the "
mklink
" command to create the new shortcut. The syntax of mklink is:mklink link target
Replacing in the above the "link" with the symbolic name and "target" with the full path to the configuration file.
So the command will be something like:
mklink 12345678-ABCD-1234-6789-ABCDEF012345.xml "drive:\your-path\Hyper-V\Virtual Machines\12345678-ABCD-1234-6789-ABCDEF012345.xml"
I found it easier to put the above together using notepad and to copy and paste the path from explorer and the file name from the properites of the xml file.
Or if you prefer to use Windows PowerShell:
- Start up Windows PowerShell
- CD to to the folder containing the shortcuts:
cd "C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines"
- To create a new symbol link enter:
New-Item -ItemType SymbolicLink -Name 12345678-ABCD-1234-6789-ABCDEF012345.xml -Target "drive:\your-path\Hyper-V\Virtual Machines\12345678-ABCD-1234-6789-ABCDEF012345.xml"
Replacing the drive, path and symbolic name with those on your machine.
- In Hyper-v Manager right click on the machine name and select "Start Service".
The virtual machine described by the symbolic link you have just recreated, should now be visible.
- You can now delete the original shortcut that you renamed by adding ".bad" to the name. (Don't delete the good one that you have just created!)
Repeat for any additional missing virtual machines.
These notes have been tested with clients running Windows 10, and may also apply to other versions of Windows.
About the author: Brian Cryer is a dedicated software developer and webmaster. For his day job he develops websites and desktop applications as well as providing IT services. He moonlights as a technical author and consultant.