Author Posts

January 11, 2016 at 1:24 am

I am planning on moving many VM's to another Hyper-V host.
This should be pretty easy, since the vm's are running on a cluster,
Here are the code.

Maybe I'm making it more difficult than it is.
Can you help me?

January 12, 2016 at 2:54 am

Hi Nicolai,

Are you saying the code is not working, or just asking for comments on if your code could be neater?

January 12, 2016 at 4:10 am

Hi Tim.
Sorry I confused you, the script was not working, but I made it harder than I should.
I have now managed to fix it.

Here is a script that Works!
#Migrating all vm's to another host without storage.
#Useful when the storage is on a cluster volume
$SourceHost = "secretservername1"
$DestinationHost = "Secretservername2"
$VMsOnHost = Get-VM -ComputerName $SourceHost

foreach ($VM in $VMsOnHost){
   Write-Host ("Moving "+$VM.Name)
   Move-VM -ComputerName $SourceHost -Name $VM.Name -DestinationHost $DestinationHost

January 12, 2016 at 4:25 am

Ah, glad to see you got it working! Didn't have a configuration i could test it on first to see.