CarlosDionizio
Contributor
Contributor

Report with IP and NetworkAdapter

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!

0 Kudos
3 Replies
LucD
Leadership
Leadership

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: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

CarlosDionizio
Contributor
Contributor

Yes! I have more than 1 NIC :smileyconfused:

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??

0 Kudos
CarlosDionizio
Contributor
Contributor

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?

0 Kudos