Move a Hyper-V Virtual Machine

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-VMStorage.

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..

Hyper-V move

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!

Leave a Reply

Your email address will not be published. Required fields are marked *

Notify me of followup comments via e-mail. You can also subscribe without commenting.