Automation

 View Only
  • 1.  How to get IP from a VMkernel port please

    Posted Jan 18, 2011 07:03 AM

    hi!

    I am writing a script to get the IP address and subnet mask for a VMkernel port (NFS ports for storage connectivity) for our host servers, to save their config prior to upgrading to v4.1. the script is almost done but I'm having difficulties with some parts of my script. For example:

       #get the NFS VMkernel port IP address details for each host
       $NFSportgroups = Get-VirtualPortGroup -vmhost $hostsvr | Where {$_.name -match "nfs-"}   # our NFS port names are preceeded with "nfs-"

       foreach ($pg in $NFSportgroups)
       { 
          $NFSip = ??

          $NFSsubnet = ??
       }

    Similarly, I'm having difficulties getting a host server IP, subnet, gateway and VMotion IP for ESXi4 hosts - my script works fine for ESX3.5 hosts, so please provide assistance with the code I need for this too!

    thanking you in advance!

    Ross



  • 2.  RE: How to get IP from a VMkernel port please

    Broadcom Employee
    Posted Jan 18, 2011 07:46 AM

    Hi,

    In order to get VMKernel IP information you need to examine VMKernel virtual netwrok adapter using Get-VMHostNetworkAdapter cmdlet:

    Get-VMHostNetworkAdapter -VMKernel -vmhost $hostsvr | Where {$_.PortGroupName -match "nfs-"}

    Regards,

    Yasen Kalchev

    PowerCLI Dev team



  • 3.  RE: How to get IP from a VMkernel port please

    Posted Jan 18, 2011 08:16 AM

    The answer to the 2nd question is similar

    Get-VMHostNetworkAdapter -VMHost $hostsvr | where {$_.PortgroupName -like "Management*"}

    Btw I think Yasen's line should say

    Get-VMHostNetworkAdapter  -VMKernel -vmhost $hostsvr | Where {$_.PortgroupName -match "nfs-"}

    Update: I see Yasen corrected the line

    Message was edited by: LucD



  • 4.  RE: How to get IP from a VMkernel port please

    Broadcom Employee
    Posted Jan 18, 2011 08:21 AM

    There's a small error in Yasen's example. The code should read:

    Get-VMHostNetworkAdapter -VMKernel -VMHost $vmhost | Where {$_.PortGroupName -match "nfs-"}

    why not create an overview for all VMkernel ports, so you have ESXi management ports too, in one run. Simply remove the Where statement.

    Get-VMHostNetworkAdapter -VMKernel -VMHost $vmhost | Select Name,PortGroupName,IP,SubnetMask