{"id":454,"date":"2019-06-11T09:53:40","date_gmt":"2019-06-11T14:53:40","guid":{"rendered":"http:\/\/itblog.ldlnet.net\/?p=454"},"modified":"2019-06-11T09:53:40","modified_gmt":"2019-06-11T14:53:40","slug":"hyper-v-general-access-denied-error-when-trying-to-load-a-virtual-hard-drive-and-start-a-vm","status":"publish","type":"post","link":"https:\/\/itblog.ldlnet.net\/index.php\/2019\/06\/11\/hyper-v-general-access-denied-error-when-trying-to-load-a-virtual-hard-drive-and-start-a-vm\/","title":{"rendered":"Hyper-V General Access Denied error when trying to load a Virtual Hard Drive and start a VM"},"content":{"rendered":"\n<p>I was working on setting up a VM for my server farm and mis-configured one of the vhdx drives. I ended up having to delete that drive and recreate it in Hyper-V manager. When I did though, I received an error stating that I could not start the virtual machine:<\/p>\n\n\n\n<p class=\"has-text-color has-small-font-size has-purple-color\"><em>An error occurred while attempting to start the selected virtual machine(s).<br>\u2018VMName\u2019 failed to start. (Virtual machine ID \u2018SomeID\u2019)<br>\u2018VMName\u2019 Microsoft Emulated IDE Controller (Instance ID \u2018SomeID\u2019): Failed to Power on with Error \u2018General access denied error\u2019 (0x80070005). (Virtual machine ID \u2018SomeID\u2019)<br>\u2018VMName\u2019: IDE\/ATAPI Account does not have sufficient privilege to open attachment \u2018C:\\Users\\Public\\Documents\\Hyper-V\\Virtual hard disks\\DiskName.vhdx\u2019. Error: \u2018General access denied error\u2019 (0x80070005). (Virtual machine ID \u2018SomeID\u2019)<br>\u2018VMName\u2019:\u00a0 Account does not have sufficient privilege to open attachment \u2018V:\\Hyper-V\\Virtual hard disks\\DiskName.vhdx\u2019. Error: \u2018General access denied error\u2019 (0x80070005). (Virtual machine ID \u2018SomeID\u2019)<\/em><\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Causes<\/h4>\n\n\n\n<p>Each virtual machine is started using a virtual machine account. The virtual machine account needs read and write access to the .vhd\/.vhdx file, but if the file has just been copied from somewhere then it most likely lacks the necessary file permissions. <br>That happened in my case because I had just created the vhdx drive and did not create it from the VM itself. I just attached it to the VM. So, when I booted the VM, it gave the error. <\/p>\n\n\n\n<h4 class=\"wp-block-heading\">Remediation<\/h4>\n\n\n\n<p>There are a few ways that you could remediate the issue. The simplest way, if it is a new VM, is to remove the drive in the VM settings and then re-create it from scratch. That is what fixed it for me.<br>Another way is to add the VM GUID to the permissions so that it can access the vhdx file properly:<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>If you don&#8217;t already have the Hyper-V Manager error dialog open (&#8220;An error occurred while attempting to start the selected virtual machine(s) &#8230;&#8221;) then try to start the virtual machine now. You need the error open.<\/li><li>Click &#8220;See details&#8221;. This will show additional details, and will look something like:<\/li><\/ul>\n\n\n\n<p class=\"has-text-color has-small-font-size has-purple-color\">&#8216;PC-Name&#8217; failed to start. (Virtual machine ID B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD) &#8216;PC-Name&#8217; Microsoft Emulated IDE Controller (Instance ID XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX): Failed to Power on with Error &#8216;General access denied error&#8217; (0x80070005). (Virtual machine ID B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD)<br>&#8216;PC-Name&#8217;: IDE\/ATAPI Account does not have sufficient privilege to open attachment &#8216;E:\\Hyper-V\\PC-Name\\Virtual Hard Disks\\MyVHD.vhdx&#8217;. <br>Error: &#8216;General access denied error&#8217; (0x80070005). (Virtual machine ID B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD)<br>&#8216;PC-Name&#8217;: Hyper-V Virtual Machine Management service Account does not have sufficient privolege to open attachment &#8216;E:\\Hyper-V\\PC-Name\\Virtual Hard Disks\\MyVHD.vhdx&#8217;. <br>Error: &#8216;General access denied error&#8217; (0x80070005). (Virtual machine ID B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD)<br>Where PC-Name will be the name of your virtual PC. The long sequence of letters and numbers (in my case above &#8220;B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD&#8221;) is the Virtual Machine ID. This number is significant and you need it to fix the problem.<\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>On the host server open an elevated command prompt.<\/li><\/ul>\n\n\n\n<ul class=\"wp-block-list\"><li>Enter the following:<\/li><\/ul>\n\n\n<pre class=\"lang:PowerShell nums:False\" title=\"Cmdlet to change file permissions on VM vhdx file\">icacls \"full-path-to-vhd-or-vhdx-file\" \/grant \"NT VIRTUAL MACHINE\\Virtual-Machine-ID\":(F)<\/pre>\n\n\n\n<p>You will need to substitute the path to the vhd\/vhdx file &#8211; you can obtain this from the original error message, and the Virtual-Machine-ID that you obtained from the &#8220;See details&#8221; part of the error.<br><br>So the line for me was:<\/p>\n\n\n<pre class=\"lang:PowerShell nums:False\">icacls \"V:\\LDLNET\\Hyper-V\\PC-Name\\Virtual Hard Disks\\MyVHD.vhdx\" \/grant \"NT VIRTUAL MACHINE\\B9C4F7D4-0009-4BE2-90FB-9D60B1A06BDD\":(F)<\/pre>\n\n\n\n<p style=\"text-align:center\" class=\"has-text-color has-small-font-size has-medium-pink-color\"><strong>NOTE: If you get the message &#8220;Failed processing 1 files&#8221; then check the virtual machine ID.<\/strong><\/p>\n\n\n\n<ul class=\"wp-block-list\"><li>Now try to start the virtual machine. The error should no longer be present.<\/li><\/ul>\n\n\n\n<p>There is also a PowerShell Gallery script that is supposed to remediate this issue: <br><br><a rel=\"noreferrer noopener\" href=\"http:\/\/www.ntsystems.it\/page\/PS-Restore-VMPermissionps1.aspx\" target=\"_blank\">http:\/\/www.ntsystems.it\/page\/PS-Restore-VMPermissionps1.aspx<\/a><br><br>I haven\u2019t tried it but it looks as it would work.  Please review and leave a comment should you have issues with the script.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" style=\"text-align:center\">HAPPY TROUBLESHOOTING!<br>PLEASE COMMENT!<br>POSITIVE ENERGY!<\/h2>\n\n\n\n<p class=\"has-small-font-size\"><strong><em>REFERENCES:<\/em><\/strong><br><em><a rel=\"noreferrer noopener\" aria-label=\"Resolved: Hyper-V General access denied error when trying to load a Virtual Hard Drive (opens in a new tab)\" href=\"https:\/\/kx.cloudingenium.com\/microsoft\/servers\/hyper-v\/resolved-hyper-v-general-access-denied-error-trying-load-virtual-hard-drive\/\" target=\"_blank\">Resolved: Hyper-V General access denied error when trying to load a Virtual Hard Drive<\/a><\/em><br><em><a rel=\"noreferrer noopener\" aria-label=\"Restore-VMPermission (opens in a new tab)\" href=\"https:\/\/ntsystems.it\/PowerShell\/Restore-VMPermission\/\" target=\"_blank\">Restore-VMPermission<\/a><\/em><br><em><a href=\"http:\/\/www.cryer.co.uk\/brian\/windows\/hyper-v-server\/help_failed_to_start_vhdx_general_access_denied_error.htm\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\"Virtual machine fails to start with General access denied error \/ Account does not have sufficient privilege to open attachment (opens in a new tab)\">Virtual machine fails to start with General access denied error \/ Account does not have sufficient privilege to open attachment<\/a><\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>I was working on setting up a VM for my server farm and mis-configured one of the vhdx drives. I ended up<\/p>\n<p class=\"link-more\"><a class=\"myButt \" href=\"https:\/\/itblog.ldlnet.net\/index.php\/2019\/06\/11\/hyper-v-general-access-denied-error-when-trying-to-load-a-virtual-hard-drive-and-start-a-vm\/\">Read More<\/a><\/p>\n","protected":false},"author":1,"featured_media":316,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[2,140,3,16],"tags":[15,34,153,8,20],"class_list":["post-454","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-general","category-hyper-v","category-powershell","category-windows","tag-cmdlet","tag-hyper-v","tag-permissions","tag-powershell","tag-windows","odd"],"_links":{"self":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/454","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/comments?post=454"}],"version-history":[{"count":2,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/454\/revisions"}],"predecessor-version":[{"id":456,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/posts\/454\/revisions\/456"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media\/316"}],"wp:attachment":[{"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/media?parent=454"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/categories?post=454"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/itblog.ldlnet.net\/index.php\/wp-json\/wp\/v2\/tags?post=454"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}