I’m doing some housekeeping today on a Hyper-V server. Wanted to move some virtual machine configuration files from one drive to another.
Most articles I found talk about stopping services, updating symlinks in C:\ProgramData\Microsoft\Windows\Hyper-V\Virtual Machines, moving files, then using icacls to update permissions so Hyper-V will be able to access the files again. Ugh.
Fortunately, I came across Jorge Bernhardt’s article that boils all of that down to one short PowerShell command:
Move Configuration Files Only
Move-VMStorage -Name "myVMName" -VirtualMachinePath "<new physical path>"
Works instantly and, to my surprise, it even works when the virtual machine is running. How cool is that?
The only oddity is that it creates an empty “UndoLog configuration” folder on the target. Maybe it uses that temporarily during the move. I’m just deleting it now that the move is complete..
Move All Files
I didn’t need this today but document for future reference:
Move-VMStorage -DestinationStoragePath "<new physical path>" -Name "myVMName"
Jorge has a couple more examples: moving individual VHD/VHDX files and moving configuration and disk files to different destinations. Great stuff, thanks Jorge!