Resolved: Hyper-V General access denied error when trying to load a Virtual Hard Drive
Recently I was working with my VMs and moving their storage files from one location to another. I don’t recall exactly what I did that caused this issue but I was unable to start my VM. I would get every time the following error message:
An error occurred while attempting to start the selected virtual machine(s).
‘VMName’ failed to start. (Virtual machine ID ‘SomeID’)
‘VMName’ Microsoft Emulated IDE Controller (Instance ID ‘SomeID’): Failed to Power on with Error ‘General access denied error’ (0x80070005). (Virtual machine ID ‘SomeID’)
‘VMName’: IDE/ATAPI Account does not have sufficient privilege to open attachment ‘C:\Users\Public\Documents\Hyper-V\Virtual hard disks\DiskName.vhdx’. Error: ‘General access denied error’ (0x80070005). (Virtual machine ID ‘SomeID’)
‘VMName’: Account does not have sufficient privilege to open attachment ‘C:\Users\Public\Documents\Hyper-V\Virtual hard disks\DiskName.vhdx’. Error: ‘General access denied error’ (0x80070005). (Virtual machine ID ‘SomeID’)
Not sure what originates this issue, but as the error message indicates Hyper-V does not have enough permissions (/sufficient priviledge) to open the attached hard drive. If I open a Virtual Machine Disk of a VM that works I can see there is an account on the Security settings tab that looks like virtual machine ID. When I go into the VHDX file for the one that is not working I can see it only has the standard accounts that are inherited by the parent folder. Clearly at some point the file permissions were lost, hence it cannot be opened.
There are many things you could do at this point. The idea at the end of the day is to get that VM account the rights it needs to open the hard drive.
The most tempting solution is to simply go to the security tab and add the account. Set the permissions like those of other VMs (At the very least read and write permissions. I fear there is a lot of room for error on this approach so it is not my favorite. There is always the possibility you missed a setting and something might not work as intended. This brings me to my second and favorite solution:
Use Hyper-V manager to remove the disk from the Virtual Machine and then go back in to add it again. Apparently every time you add a virtual hard disk it will execute the required commands to give that Virtual Machine account the required permissions to the attachments. I say apparently because I can’t imagine how this didn’t happen in my case and I ended up getting the error message. Regardless, doing this did solve my issue and it is the Hyper-V manager fixing the permissions so I feel more confident it will get done correctly.
Finally there are many other ways to modify file permissions that you could use. Most importantly, there is always PowerShell. There is a “AddAccessRule” command you could apply to a VirtualMachine.HardDrive that will, of course, add the required access rules so that the VM can access said attached Virtual Hard Drive. Pretty neat right?
There is one said script that you could use found here: http://www.ntsystems.it/page/PS-Restore-VMPermissionps1.aspx. I haven’t tried it but it looks as it would work. I only had one VM to fix so it is much faster to do the Hyper-V manager operation than trying to download and then validate the script before executing it. But if you want to do this for a number of VMs you could use this to run it against