VMware Cloud Community
Gael
Contributor
Contributor

how to manipulate .list() as array?

Hi,

I'm trying to manipulate data output from a $esxcli.network.nic.list() as an array.... but it seems it's not an array?!
Is there a solution to manipulate output from a *.list() ?

Thanks,

Tags (2)
0 Kudos
6 Replies
LucD
Leadership
Leadership

The output produced is of type EsxCliObjectImpl, but you can use most regular cmdlets to handle the result.

For example

$esxcli.network.nic.list() |

Export-Csv -Path report.csv -NoTypeInformation -UseCulture

Is there anything specific you want to do with the output?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Gael
Contributor
Contributor

Hi LucD,

In fact i'ld like to identify different model of NIC (ie : if one card dual port & one card quad port, I'ld like to see 2 values), used driver with is version, vid and did...

0 Kudos
LucD
Leadership
Leadership

I'm not sure you will find that information with that command.

Can you perhaps show what you want to extract from the output?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Gael
Contributor
Contributor

Sure, I'll not be able to find all information with this command but it'll be the best source to identify NIC name or model, and use it as argument with another commands Smiley Happy
the goal is to put all these information, with others, in a excelsheet...

0 Kudos
LucD
Leadership
Leadership

You mean like this?

$esxcli.network.nic.list() | Select Name,Description

Which you can export to a CSV

$esxcli.network.nic.list() |

Select Name,Description |

Export-Csv -Path report.csv -NoTypeInformation -UseCulture


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Gael
Contributor
Contributor

Yes, but the csv must contains also lot of others information...

If I use Export-Csv, I'll not be able to manipulate others data easily.

In fact, I made mistake using [] with .list()

And finally, this basic solution is sufficient for my needs !

$vmniclist = get-esxcli -VMhost $host

$vmniclist = $vmniclist.network.nic.list()

$vmnic0Name = $vmniclist[0].Name

$vmnic0Desc = $vmniclist[0].Decription

[...]

Thanks a lot LucD Smiley Happy

0 Kudos