Automation

 View Only
  • 1.  View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 08:23 AM

    Dears,

    Is there any way to find the vMotion enabled IP address with VLanID. I am looking for a table like VMHost, vMotion IP, VLanID.

    Thanks in advance.

    Rajesh Bhuvanan



  • 2.  RE: View ALL vMotion IPs with VLanID
    Best Answer

    Posted Apr 29, 2015 09:58 AM

    Try something like this

    foreach($esx in Get-VMHost){

        foreach($vmk in (Get-VMHostNetworkAdapter -VMHost $esx | where {$_.VMotionEnabled})){

            Get-VirtualPortGroup -Name $vmk.PortGroupName -VMHost $esx |

            Select @{N='VMHost';E={$vmk.VMHost.Name}},@{N='PG';E={$_.Name}},VlanId,@{n='IP';E={$vmk.IP}}

        }

    }

               

    Note that this will not show the VlanId for distributed switches.



  • 3.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:25 AM

    Dear LucD,

    It worked. Appriciate your efforts.

    Just one question. Is there any way to sort the table based on the VMHostname ?

    Regards

    Rajesh



  • 4.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:27 AM

    Sure, one way is like this

    foreach($esx in (Get-VMHost | Sort-Object -Property Name)){

        foreach($vmk in (Get-VMHostNetworkAdapter -VMHost $esx | where {$_.VMotionEnabled})){

            Get-VirtualPortGroup -Name $vmk.PortGroupName -VMHost $esx |

            Select @{N='VMHost';E={$vmk.VMHost.Name}},@{N='PG';E={$_.Name}},VlanId,@{n='IP';E={$vmk.IP}}

        }

    }



  • 5.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:34 AM

    Dear LucD,

    Great it worked.

    I have added Get-Cluster to it also like foreach($esx in Get-Cluster "ClusterName" | Get-VMHost | Sort-Object -Property Name) . It was perfect.

    Thanks a lot.

    Rajesh.



  • 6.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:05 AM

    Use this:

    Get-VMHost | Get-VMHostNetworkAdapter -VMKernel | Where { $_.VMotionEnabled -eq $true } | Select VMHost, Name, IP, PortGroupName,
      @{N='VLAN'; E={(Get-VirtualPortGroup -VMHost $_.VMHost  -Name $_.PortGroupName).ExtensionData.Config.DefaultPortConfig.Vlan.VlanId}} | Format-Table -autosize



  • 7.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:27 AM

    Dear MKguy,

    Thanks for the script, but I didn't get anything for VLan. The other fields displayed.

    Regards

    Rajesh



  • 8.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:41 AM

    Ah, seems like my version only works for distributed vSwitches while LucD's version only works with standard vSwitches.



  • 9.  RE: View ALL vMotion IPs with VLanID

    Posted Apr 29, 2015 10:44 AM

    Dear MKguy,

    Great, so I can keep both scripts.

    Regards

    Rajesh