Monday, September 26, 2016

Hyper-V Manager Error 'General access denied error'

Hello there,

Recently I started using Hyper-V to set up a lab in my workstation.  I created many virtual machines in a domain environment to test traditional Window Server Fail over Cluster with SQL Server 2016 and also other nodes for testing availability groups.  Long story short I started running low on free space on my 256GB SSD so I ended up buying crucial MX300 750GB SSD for replacement.  After copying the contents from the existing 256GB SSD into 750GB SSD I started checking everything out to make sure that copy process worked as expected.  When I attempted to start the virtual machines in the Hyper-V Manager I kept getting errors for all the virtual machines and it basically said that the access denied.  The screenshot of the error message captured below.


I thought somehow the file system permissions did not transfer properly and tried granting my account full access to the D: drive where I store the virtual machine files.  To my suprise it did not change anything and the same error message appeared again.  Then I turned to my favorite search engine and looked for a solution.   Which was very easy to implement and I wanted to share it and keep a record of it in my blog in case I run into it again in the future.

The solution was to simple opening a Command Prompt (Admin) and gather couple of information for the command to execute and grant the necessary privileges to the virtual machine file. The command is;

icacls "path to vhd or vhdx file" /grant "NT VIRTUAL MACHINE\Virtual Machine ID":F

I knew the virtual machine file name and full path to it but I needed to find the virtual machine SID.  To get the SID you need just click on 'See details' link on the error message window and it will expand the error window like below.


The last paragraph has the full path of my virtual machine file and the SID I needed for the command.  So I just opened the Command Prompt (Admin) and I typed the command as seen below and then I was able to start the virtual machine and connect to it.



Happy virtualizations.
HTH,
Bulent