3 Replies Latest reply on Oct 4, 2013 8:50 AM by CarlosDionizio

    Report with IP and NetworkAdapter

    CarlosDionizio Novice

      Hi! Friends!

       

      how can i add IP and networkadapter on this line?

       

      Get-VM dvml*| Select Name,VMHost,NumCPU,PowerState,MemoryMB,@{N="Datastore"; E={$_ | sort-object -property Name |

      Get-Datastore}} | ConvertTo-HTML -title "Relação de Servidores - VMWARE" -body  "<H2>Relação de Servidores - VMWARE</H2>" -head $aforma| Out-File report.html

       

      Tks to any help!

        • 1. Re: Report with IP and NetworkAdapter
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          If you only have 1 NIC per VM you can do something like this

           

          Get-VM dvml*| | 
          Sort-Object -Property Name |
          Select Name,VMHost,NumCPU,PowerState,MemoryMB,
           
          @{N="NIC";E={$_.NetworkAdapters[0].Name}},
           
          @{N="IP";E={$_.Guest.IPAddress[0]}},
           
          @{N="Datastore"; E={$_ | Get-Datastore}} |
          ConvertTo-HTML -title "Relação de Servidores - VMWARE" -body  "<H2>Relação de Servidores - VMWARE</H2>" -head $aforma|
          Out-File report.html

          If you have more than 1 NIC, the script needs another loop through all the NICs

          Blog: http://lucd.info | Twitter: @LucD22 | PowerCLI Reference co-author: http://tinyurl.com/hkn4glz
          1 person found this helpful
          • 2. Re: Report with IP and NetworkAdapter
            CarlosDionizio Novice

            Yes! I have more than 1 NIC

             

            I try to put MacAddress and NetworkName but all field return in zero

            Get-VM dvml*|
            Sort-Object -Property Name |
            Select Name,VMHost,NumCPU,PowerState,MemoryMB,
             
            @{N="NIC";E={$_.NetworkAdapters[0].Name}},
             
            @{N="IP";E={$_.Guest.IPAddress[0]}},

            @{N="IP";E={$_.Guest.NetworkName[0]}},

            @{N="IP";E={$_.Guest.MacAddress[0]}},

              @{N="Datastore"; E={$_ | Get-Datastore}} |
            ConvertTo-HTML -title "Relação de Servidores - VMWARE" -body  "<H2>Relação de Servidores - VMWARE</H2>" -head $aforma|
            Out-File report.html


            How can i find this attributes/fields  Guest.IPAddress and NetworkAdapters?

            In old powercli version using get-vm i can  see all fields, but not in this new VMware-PowerCLI-5.1.0-1012425

            get-vm return only Name,PowerState, Num CPUs, MemoryGB is correct? only 5 fields attributes??

            • 3. Re: Report with IP and NetworkAdapter
              CarlosDionizio Novice

              I got it right!

               

              @{N="Lan_ID";E={$_.NetworkAdapters[0].NetworkName}},

              @{N="MacAddress";E={$_.NetworkAdapters[0].MacAddress}},

               

              So the new version of the properties were split into news
              cmds? and need to use join?