Saturday 9 December 2017

PowerShell TotD: Hyper-V Live Move a specific VHDX file

There are times when we need to move one of two VHDX files associated with a VM.

The following is the PowerShell to do so:

Poll Hyper-V Host/Node for VM HDD Paths

get-vm "*" | Select *path,@{N="HDD";E={$_.Harddrives.path}} | FL

Move a Select VHDX

Move-VMStorage -VMName VMName -VHDs @(@{"SourceFilePath" = "X:\Hyper-V\Virtual Hard Disks\VM-LALoB_D0-75GB.VHDX"; "DestinationFilePath" = "Y:\Hyper-V\Virtual Hard Disks\VM-LALoB_D0-75GB.VHDX"})

Move-VMStorage Docs

The Move-VMStorage Docs site. This site has the full syntax for the PowerShell command.

Conclusion

While the above process can be initiated in the GUI, PowerShell allows us to initiate a set of moves for multiple VMs. This saves on time bigtime versus mouse.

By the way, TotD means: Tip of the Day.

Thanks for reading! :)

Philip Elder
Microsoft High Availability MVP
MPECS Inc.
Co-Author: SBS 2008 Blueprint Book
Our Web Site
Our Cloud Service

No comments: