3 Replies Latest reply on Jan 18, 2011 12:16 AM by LucD

    How to get IP from a VMkernel port please

    Ross Walter Novice

      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

        • 1. Re: How to get IP from a VMkernel port please
          ykalchev Expert
          VMware Employees

          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

          • 2. Re: How to get IP from a VMkernel port please
            LucD Guru
            Community WarriorsvExpertUser Moderators

            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

            Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
            • 3. Re: How to get IP from a VMkernel port please
              avlieshout Expert
              VMware Employees

              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