Automation

 View Only
  • 1.  Validate storage vmotion compatibility with powerCLI

    Posted Nov 11, 2017 02:45 AM

    If I use vSphere Web Client to storage vMotion a VM, it does a compatibility / validation when I select the datastore and tells me whether the storage vmotion will succeed before I try it.  If there are any issues such as the datastore isn't mounted to the ESXi host the VM is on - it will tell me before I attempt the sVmotion and the compatibility check / validation will fail.

    What I'd like to do is take a VM I'm about to sVmotion and do a compatibility check before I actually attempt the storage vMotion and see if there are any issues first.

    Can this be done in PowerCLI?

    Thanks!



  • 2.  RE: Validate storage vmotion compatibility with powerCLI

    Posted Nov 11, 2017 09:35 PM

    No cmdlet for that I'm afraid, but the RecommendDatastores method should be able to provide that information.



  • 3.  RE: Validate storage vmotion compatibility with powerCLI

    Posted Nov 11, 2017 11:59 PM

    OK thanks again. That might actually work. But how would I use it? How would I compare the data store that I want to move my VM to to the list of recommended data stores and see if the data store I want to move it to is in the list?



  • 4.  RE: Validate storage vmotion compatibility with powerCLI
    Best Answer

    Posted Nov 13, 2017 03:22 PM

    Try the following method, I think that is more like the Web Client is showing.

    $vmName = 'MyVM'

    $tgtDSName = 'MyDS'

    $vm = Get-VM -Name $vmName

    $ds = Get-Datastore -Name $tgtDSName

    $si = Get-View ServiceInstance

    $vmProvCheck = Get-View -Id $si.Content.VmProvisioningChecker

    $spec = New-Object VMware.Vim.VirtualMachineRelocateSpec

    $spec.Datastore = $ds.ExtensionData.MoRef

    $result = $vmProvCheck.CheckRelocate($vm.ExtensionData.MoRef,$spec,$null)

    $result | %{

        $_.Error | Select @{N='Message';E={$_.LocalizedMessage}}

    }



  • 5.  RE: Validate storage vmotion compatibility with powerCLI

    Posted Nov 13, 2017 05:27 PM

    Great help - OK thanks again