Configure Hyper-V VM powershell
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:
TO:
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?
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-web',
'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
}
$MoveOptions
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'