VMware Cloud Community
Azarou
Enthusiast
Enthusiast

Script to list VM that cannot be vmotioned

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 ?

0 Kudos
5 Replies
LucD
Leadership
Leadership

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


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

0 Kudos
Azarou
Enthusiast
Enthusiast

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

0 Kudos
LucD
Leadership
Leadership

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 ?


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

0 Kudos
Azarou
Enthusiast
Enthusiast

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

That's it

0 Kudos
LucD
Leadership
Leadership

Try like this

Get-VMHost  |

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

Get-VM |

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


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

0 Kudos