VMware Cloud Community
robertandru
Contributor
Contributor

VMotion script

I have a request to identify in our environment what dependency is conflicting with VMotion move in clusters. If somebody has any knowledge of such a script, which can be executed to the VCenter and identify VM's which will have conditions and limitations to migrate on different nods in the cluster during a maintenance mode stage, please share.

Need to validate this before patching using VUM process

Thanks in advance for your help.

Cheers,

Tags (1)
0 Kudos
3 Replies
scott28tt
VMware Employee
VMware Employee

Moderator: Moved to PowerCLI (which is the most likely solution)


-------------------------------------------------------------------------------------------------------------------------------------------------------------

Although I am a VMware employee I contribute to VMware Communities voluntarily (ie. not in any official capacity)
VMware Training & Certification blog
0 Kudos
LucD
Leadership
Leadership

There currently isn't a cmdlet for that, but there is the QueryVMotionCompatibilityEx_Task method.

You can run these tests with something like this.

Note that this method might be very verbose, especially in the Warnings section with missing guest OS heartbeats.
You might start by only looking at the Error section.

$clusterName = 'cluster'


$si = Get-View ServiceInstance

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


$cluster = Get-Cluster -Name $clusterName

$vmMoRef = (Get-VM -Location $cluster).ExtensionData.MoRef

$esxMoRef = (Get-VMHost -Location $cluster).ExtensionData.MoRef


$checkMgr.QueryVMotionCompatibilityEx($vmMoRef,$esxMoRef) |

ForEach-Object -Process {

    $vm = Get-View -Id $_.VM -Property Name

    $esx = Get-View -Id $_.Host -Property Name

    if($_.Warning){

        $_.Warning | ForEach-Object -Process {

            [PSCustomObject]@{

                VMHost = $esx.Name

                VM = $vm.Name

                Type = 'Warning'

                Message = $_.LocalizedMessage

            }

        }

    }

    if($_.Error){

        $_.Error | ForEach-Object -Process {

            [PSCustomObject]@{

                VMHost = $esx.Name

                VM = $vm.Name

                Type = 'Error'

                Message = $_.LocalizedMessage

            }

        }

    }  

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
robertandru
Contributor
Contributor

Thanks, LucD. Let me test the result and get back.

Cheers,

0 Kudos