How can i reconfigure Hyper-V VM's

I want to be able to change the VM configuration file, check points, and virtual hard drive locations with Powershell.

My Google-FU is only pointing me at moving, I have about ~100 VM's to Change, I can move the files, I do not mind a little downtime, When walking throught the wizard for each VM it takes about 5 to 15 minutes per VM and those are the smaller ones, I need to be able to do all 100 in 2 hours.

If i need to clarify please let me know.

==Where I am getting stuck==

Yes i have seen that link and looked at most of the commands however none do what I am looking for.

The files all together are about 14 TB

The ~100 VM's are clustered between 7 Hosts. The shared storage is EMC spinning disk and I want to move them to 3Par ssd.

Now, what I have been able to do successfully was shut the VM's down, move the files, delete all the VM's and recreate them VIA powershell, which when I told my CTO that may be the only way he about shit kittens.

What i want to be able to is not MOVE the VM's just RECONFIGURE them,

In other works be able to change:

enter image description here


enter image description here

I want to be able to do this using powershell, Also i need to be able to do the same thing for the checkpoints, and configuration files, and all other Hyper-V VM components.

I can tolerate about 2 hours of downtime, to do the MOVE through the wizard for all the VM's will not only wear out my mouse but take about 6 hours.

I have also been researching this and testing out different strategies for a couple weeks now.

====One More Shot====

I am not looking to "Move" all i want to be able to do is change the settings from within hyper-V moving will take way to long, it is much quicker for me to copy the files over the network and just update the paths in Hyper-V, I can shut the machines down.

Im thinking it cannot be done?

  • What kind of research have you done so far? The documentation in the hyper-v module seems pretty good to me. Where are you getting stuck? – Zoredache Sep 5 '17 at 21:44
  • @Zoredache please look at update. – Anthony Fornito Sep 5 '17 at 22:06
  • 1
    If they are clustered you just need to move the storage, using the move storage option. It is in the GUI and should result in no downtime. blogs.msdn.microsoft.com/clustering/2012/04/26/… – Drifter104 Sep 5 '17 at 22:09
  • Im thinking it cannot be done? I think it can be done, but it would be a long and complicated script. Pretty much everything about a VM can be fully manipulated via powershell. I suspect you are making your life far more difficult by not letting the tools manage the move of the files for you. – Zoredache Sep 6 '17 at 17:35
  • @Zoredache in a perfect world where I had 6 hours yes it would be fine to use the tools, however I have 2 – Anthony Fornito Sep 6 '17 at 18:08

Not really sure this does what you need but there is an example powershell fragment I have used in the past to migrate VMs including the all the storage to a new destination

Get-VM -Name ('ansible-test-acs',
              'ansible-test-db') |
ForEach-Object {
    # move everything to d:\hyper-v\vm_name on hv-srv-01
    $MoveOptions = @{
        'Name'                   = $_.Name
        'DestinationHost'        = 'hv-srv-01'
        'IncludeStorage'         = $true
        'DestinationStoragePath' = 'D:\Hyper-V\{0}' -f $_.Name
    Move-VM @MoveOptions -WhatIf
    # Move-VM @MoveOptions

Move VM storage to a new path

('ansible-test-web', 'ansible-test-db') |
ForEach-Object {
    Move-VMStorage $_ `
            –DestinationStoragePath "E:\Hyper-V\$_"

If you have copied a VM and all its files to a new location and you want Hyper-V to start using the new location, then you should be able to do something like.

Remove-VM oldvmname
Import-VM -Register -Path 'path to VM config file'
  • Thanks for the code but it still moves the VM's see update – Anthony Fornito Sep 6 '17 at 15:34
  • You saw the option to move just the storage right? – Zoredache Sep 6 '17 at 17:45
  • Yes, but I am not looking to 'MOVE' the storage, I have copied over the vhdx file to the new location, also I can use the Set-VMHardDiskDrive command which does work for changing the directory of storage when the VM is off, which is also fine, but I cannot find out how to 'CHANGE' the pointer for the VM configuration file. – Anthony Fornito Sep 6 '17 at 18:07
  • If you have actually copied all the files and you are certain, Then remove the remove, and re-import the VM. Answer updated with an example. – Zoredache Sep 6 '17 at 18:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.