1 Reply Latest reply on Feb 10, 2016 3:15 AM by linotelera

    How to programatically get the vm-name and UUID of this VM provided i have hostname and ipaddres.

    lazern Lurker

      I have a CentOS-6 VM i need to get the vm-name and UUID of this VM provided i have hostname and ipaddres.

        • 1. Re: How to programatically get the vm-name and UUID of this VM provided i have hostname and ipaddres.
          linotelera Hot Shot
          vExpert

          Hi

          using powercli and vmware tools running in Centos guest, you could use this script:

          $vm = Get-VM
          $vmview = $vm | Get-View
          Foreach ($v in $vmview){
              echo "-----------------------"
              echo $v.Name
              echo $v.Config.uuid
              echo "-----------------------"
              $Name = $v.Guest.HostName
              
              If ($Name -ne $null -and $Name -ne ""){
                  echo $Name
                  Foreach ($nic in $v.Guest.Net){
                      $IP = $nic.IPAddress
                      echo $IP
                      }
                  }
              }
              echo "-----------------------"
          
          

           

          Hope this could be useful

          regards