Hyper-V operates using a list of symbolic links in a specific directory:
· C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines
Each of these are links to the actual VM configuration files in their own respective subdirectories – whether stored locally or on shared storage, the link doesn’t change in its nature.
All you need to know in order to control which VMs are displayed in Hyper-V Manager follows:
1. First you need to identify the GUID of the specific VM. Look in the directory location for the VM you wish to manipulate and note the name of the .XML file in the Virtual Machines subdirectory.
Our example will use the LitwareSpeech VM, located at D:\VMs\LitwareSpeech. In the “D:\VMs\LitwareSpeech\Virtual Machines” path is the configuration file for this VM, named “D546B942-76AF-4C3B-97C6-9EE74828BC91.XML”
2. To delete the reference to this VM in Hyper-V Manager, browse to “C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\” and locate the symbolic link that is named after the VM GUID. Deleting this link only deletes the reference to the VM in Hyper-V Manager – it does not delete the actual configuration of the VM or the VHD.
The path “C:\ProgramData” is a hidden directory path. See “Viewing Hidden Folders” section later to complete these steps, if necessary.
3. To later restore the reference to the VM, browse to the location, “C:\ProgramData\Microsoft\Windows\Hyper-V” and Shift-RightClick on the Virtual Machines directory. Select Open Command Window Here.
4. Using the VM GUID that you determined above in Step 1, run the following command:
mklink <GUID>.XML <VMConfigPath.XML> or in our example
mklink D546B942-76AF-4C3B-97C6-9EE74828BC91.xml “D:\VMs\LitwareSpeech\Virtual Machines\D546B942-76AF-4C3B-97C6-9EE74828BC91.xml”
This restores the reference to your VM in Hyper-V Manager.
The catch to this operation that I’ve learned is that when you create a VM, Hyper-V creates a security entry (ACE) on this symbolic link for the SID of the worker process for the VM. Unfortunately, this ACE isn’t re-created when you recreate the symbolic link using mklink as detailed above.
If you try to start your re-registered VM at this point, you’re likely to receive this error message:
To address this requirement, follow these steps:
1. Again, locate and note the GUID of the VM.
2. Using this GUID, run the following command:
icacls “C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\<GUID>.xml” /grant “NT VIRTUAL MACHINE\<GUID>“:(F) /L
Or in our example from above:
icacls “C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines\D546B942-76AF-4C3B-97C6-9EE74828BC91.xml” /grant “NT VIRTUAL MACHINE\D546B942-76AF-4C3B-97C6-9EE74828BC91″:(F) /L
3. This process regenerates the necessary ACE on the symbolic link using the Service SID of the VM, rather than on the configuration file itself, replicating the initial state of the symbolic link.
4. Once this command has been run successfully, you should be able to start your VM without further issues.
Viewing Hidden Folders
1. Open Windows Explorer. Select Tools, Folder Options…
2. Select the View Tab and choose the option to “Show hidden files and folders”
3. Click OK.