Automation

 View Only
  • 1.  Script to list VM that cannot be vmotioned

    Posted Feb 24, 2016 04:40 PM

    Hi all,

    I am trying to write a script to determine which VM cannot be vmotioned.

    In our infrastructure some host are not configured with a vmkernel vmotion.

    I guess how i can do that :

    Trying something like that but without success :

    $VmHost =Get-VMHost

    Get-VM |  Get-VMHostNetworkAdapter -VMHost $VmHost.Name -VMKernel | Where {$_.VMotionEnabled -eq “true”}

    can someone help ?



  • 2.  RE: Script to list VM that cannot be vmotioned

    Posted Feb 24, 2016 05:55 PM

    You can do something like this

    Extract the VMotionEnabled property on all VMKernel vnics, then test if there is no $true value between them

    Get-VMHost  |

    where {(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel | select -ExpandProperty VMotionEnabled) -notcontains $true} |

    select Name



  • 3.  RE: Script to list VM that cannot be vmotioned

    Posted Feb 25, 2016 11:45 AM

    thanks for your reply Lucd,

    It's work but it get only the vmhostname,

    Want to know if i can get vmname from vmhost with the same script,

    Thanks for all



  • 4.  RE: Script to list VM that cannot be vmotioned

    Posted Feb 25, 2016 11:52 AM

    Sorry, I don't understand what you're asking here.

    The vmk over which vMotion occurs is a VMHost object, nothing to do with VMs.

    Unless you want to see a list of VMs on all the VMHosts where vMotion is not available ?



  • 5.  RE: Script to list VM that cannot be vmotioned

    Posted Feb 25, 2016 01:31 PM

    you want to see a list of VMs on all the VMHosts where vMotion is not available ?

    That's it



  • 6.  RE: Script to list VM that cannot be vmotioned

    Posted Feb 25, 2016 05:06 PM

    Try like this

    Get-VMHost  |

    where {(Get-VMHostNetworkAdapter -VMHost $_ -VMKernel | select -ExpandProperty VMotionEnabled) -notcontains $true} |

    Get-VM |

    Select Name,@{N='ESXi';E={$_.Host.Name}}