Move-VM

This topic contains 3 replies, has 2 voices, and was last updated by Profile photo of Tim Pringle Tim Pringle 8 months, 2 weeks ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #33688
    Profile photo of Nicolai Magnussen
    Nicolai Magnussen
    Participant

    Hi.
    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?

    #33760
    Profile photo of Tim Pringle
    Tim Pringle
    Participant

    Hi Nicolai,

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

    #33763
    Profile photo of Nicolai Magnussen
    Nicolai Magnussen
    Participant

    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
    }

    #33764
    Profile photo of Tim Pringle
    Tim Pringle
    Participant

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

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.