Hyper-V Program Manager
Yesterday I showed you how to do a simple storage migration using the Hyper-V Manager user interface. Today I want to show you how to do the same thing in PowerShell – and in my opinion it is even easier to do in PowerShell than with our user interface.
As a quick reminder – I am not showing you the complex side of storage migration (yet) I am just showing you how to accomplish the task of getting all the bits for a given virtual machine moved to a single folder, while the virtual machine continues to run. The PowerShell command for this is actually quite self explanatory:
Move-VMStorage -VMName "Windows Server 2008 R2" -DestinationStoragePath "E:\Hyper-V\Windows Server 2008 R2"
“Move-VMStorage”, the name of the virtual machine you want to move, and the name of the folder you want to move it to. Couldn’t be much simpler than that right? Well, actually it can. You see, the “-VMName” and “-DestinationStoragePath” parameter names are not required. You can actually just type this:
Move-VMStorage "Windows Server 2008 R2" "D:\Hyper-V\Windows Server 2008 R2"
Trust me, the first time you get to show this to someone who thinks that PowerShell is too complicated / tricky – you will feel like a rock star :-)
for the second senario, it works only if you have the VM Name first following by the destination path.
Correct - the second version uses positional parameters (which are discussed here: msdn.microsoft.com/.../dd878252(v=vs.85).aspx)
Realmente estou muito empolgado com o windows SRV 8!!
Thanks for this great post Benjamin :D !!
I have a question: Is possible execute the command:
Move-VMStorage -VMName $_.VMName -vhds $hash
.. in a Failover Cluster??
I'm new in PowerShell and I’m trying to move VMStorage from a Volume to another when a Cluster disk is running out space.
.. but I just received the message: "Move-VMStorage : A parameter is invalid. Hyper-V was unable to find a virtual machine with name MIXSVWDESCN02"
I'm executing the script in a Failover cluster.
Thanks in advance :)!