VMware vSphere

 View Only
  • 1.  Quick way to gather all VM guest names and IP addresses?

    Posted Nov 14, 2014 12:40 PM

    Hi,

    With ESXi 5.5, I can run:

    # vim-cmd vmsvc/get.guest <vmid>

    From the SSH console to get a summary of information about the specific VM. If VMWare tools is installed on the VM, this command also gives me the name and IP address of the VM:

    (vim.vm.GuestInfo) {

       dynamicType = <unset>,

       toolsStatus = "toolsOk",

       toolsVersionStatus = "guestToolsUnmanaged",

       toolsVersionStatus2 = "guestToolsUnmanaged",

       toolsRunningStatus = "guestToolsRunning",

       toolsVersion = "2147483647",

       toolsUpdateStatus = (vim.vm.GuestInfo.ToolsUpdateStatus) null,

       guestId = "freebsd64Guest",

       guestFamily = "otherGuestFamily",

       guestFullName = "FreeBSD (64-bit)",

       hostName = "krsy",

       ipAddress = "192.168.10.2",

    Is there any way to quickly grab this information for ALL virtual machines registered on the hypervisor? I know that I could run vim-cmd vmsvc/getallvms and then iterate through that list, running get.guest, but on a hypervisor with lots of VM's this can take a few minutes. I imagine this information is all stored together someplace, but I just haven't been able to figure out how to extract it in one shot.

    Thanks for any help you can provide.



  • 2.  RE: Quick way to gather all VM guest names and IP addresses?

    Posted Nov 14, 2014 01:31 PM

    Hi There,

    if you are keen on using PowerCLI, the script would go like this:

    # Connect directly to the ESXi host
    Connect-VIserver fqdn.domain.net

    # Retrieve all Virtual Machines and do for each object:
    Get-VM | % {
      
    #Set variables for Virtual Machine and its IP
       $virtualmachine = $_
      
    $ipaddress = ($_ | Get-VMguest).Ipaddress[0]

      
    # Create a new Hash Table and feed the values in there
       New-Object -TypeName psobject -Property @{
      VMname
    =$_
      VMip
    =$ipaddress
      }
    # Finally Export CSV
    } | Export-Csv .\ipreport.csv -UseCulture



  • 3.  RE: Quick way to gather all VM guest names and IP addresses?

    Posted Nov 14, 2014 02:20 PM

    Hi,

    You can also grab this information by using the vSphere client. It is an alternative to what Alistar posted.

    1. Open vSphere client and select your host, cluster or datacenter.

    2. Select Virtual Machines on the top bar

    3. Right click the columns and choose what you'd like to view. You can simply leave the defaults and add IP address or remove the columns you don't want.

    4. Once that view has been configured, click File ->  Export -> Export list and save it to what ever file format you like.

    That should grant you, VM guestname and IP address along with the ability to add other information if necessary.

    Hope this helps.



  • 4.  RE: Quick way to gather all VM guest names and IP addresses?

    Posted Nov 14, 2014 05:49 PM

    RVTools is your friend ... http://www.robware.net/