Automation

 View Only
  • 1.  Storage vmotion a VM with multiple datastores

    Posted Jun 19, 2017 06:22 PM

    Hi,

    I have several VMs that have .vmdk for themselves and some being shared with other VMs.

    My understanding is that "Move-VM testVM -Datastore newDS" would target all of the disks that testVM has access to and move them to newDS. If the testVM's .vmdk files reside on multiple datastores (DS1, DS3 and DS7 say), is there a way that I can specify only storage from DS7 are targeted to move to newDS.

    Better yet, is there a command to migrate the content of one datastore to a new one, and reconfigure all of the objects to use the new one.

    Thx



  • 2.  RE: Storage vmotion a VM with multiple datastores

    Posted Jun 19, 2017 07:39 PM

    I'm afraid that is not possible with a cmdlet.

    But you can use the Relocate-VM method to do this.

    See for example 11. Re: Using multiple datastores, can't migrate the vmx file to a datastore



  • 3.  RE: Storage vmotion a VM with multiple datastores

    Posted Jun 19, 2017 07:42 PM

    An alternative method, with only cmdlets, could be the following:

    • Stop the VM
    • Remove (not delete) all harddisk, sitting on the datastore, from the VM
    • Move these harddisks with the Move-HardDisk cmdlet to the desired datastore
    • Connect the harddisks back to the VM
    • Start the VM


  • 4.  RE: Storage vmotion a VM with multiple datastores

    Posted Jun 20, 2017 05:03 PM

    Hi Luc,

      The first step - "Stop the VM" - makes this approach not feasible. I looked at your other approaches: "Relocate-VM" and "Move independent disks", and I think they are more applicable to deal with with my issue.

      I will utilize your code as the foundation, wrap it with add'l tasks to fit our project's objectives, test it out and post the result later. The Relocate-VM is little bit abstracted for me ... I dont know when the "copy or storage vmotion" happens and how I would be able to control that activity. But that's what testing for!

      In short, appreciate the lead ... just that it's technically not the answer yet.



  • 5.  RE: Storage vmotion a VM with multiple datastores

    Posted Jun 20, 2017 05:16 PM

    Let me know if you get stuck.



  • 6.  RE: Storage vmotion a VM with multiple datastores

    Posted Jun 19, 2017 11:51 PM

    I used this one in the past to migrate a complete array give it a try

    Get off my array! (Scripting datastore migrations with PowerCLI) | Notes from a Sysadmin