Error when exporting Hyper-V virtual machine to USB memory stick

Recently I needed to export a Hyper-V virtual machine to another computer.

I decided to export it directly to a USB memory stick.

However it failed consistently with this error message:


An error occurred while attempting to export the virtual machine.

Failed to copy file during export.

Failed to copy file from 'C:\Users\Public\Documents\Hyper-V\Virtual Hard Disks\DeploymentTest5New4.vhdx' to 'E:\VM\DeploymentTest5\Virtual Hard Disks\DeploymentTest5New4.vhdx': One or more arguments are invalid (0x80070057).


I examined the file system on the USB stick and discovered that it was FAT32.

FAT32 has a file size limitation of 4 GB.

Most virtual machines are likely to be bigger than that and that was also the case here.


I decided to empty the USB stick and reformat it to NTFS.

Then the virtual machine could be exported without problems.

Windows file permissions: High Mandatory Level

I encountered a problem when following the guide: WinPE: Create a Boot CD, DVD, ISO, or VHD


I chose to create a new .vhdx file directly under C:\ for testing in Hyper-V

Later I moved the .vhdx file to C:\Hyper-V

I actually got this dialog when moving the file, but just went ahead with Continue without considering the implications.



When I tried to attach the .vhdx to a virtual machine I got this error message:


Failed to modify device ‘Virtual Hard Disk’.

User Account does not have permission to open attachment.


I checked the file permissions and noticed:


Integrity level: High Mandatory Level


I also checked the permissions with:

C:\>icacls c:\Hyper-V\WinPE_amd64_PS.vhdx
c:\Hyper-V\WinPE_amd64_PS.vhdx BUILTIN\Administrators:(I)(F)
NT AUTHORITY\Authenticated Users:(I)(M)
Mandatory Label\High Mandatory Level:(I)(NW)

Successfully processed 1 files; Failed processing 0 files


The high integrity level was causing the problem, but how to remove it?

The easiest solution was to lower the integrity level with:

icacls c:\Hyper-V\WinPE_amd64_PS.vhdx /setintegritylevel medium

After that the file could be attached and used.



If high integrity level on a file causes problems, it can be lowered with icacls.

Generally avoid creating files directly under C:\, because it can lead to problems like this.