Automation

 View Only
  • 1.  VMotion script

    Posted Feb 19, 2020 07:13 PM

    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,



  • 2.  RE: VMotion script

    Posted Feb 19, 2020 08:36 PM

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



  • 3.  RE: VMotion script

    Posted Feb 19, 2020 09:00 PM

    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

                }

            }

        }  

    }



  • 4.  RE: VMotion script

    Posted Feb 19, 2020 10:23 PM

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

    Cheers,