Automation

 View Only
  • 1.  how to manipulate .list() as array?

    Posted Feb 12, 2018 05:01 PM

    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,



  • 2.  RE: how to manipulate .list() as array?

    Posted Feb 12, 2018 05:07 PM

    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?



  • 3.  RE: how to manipulate .list() as array?

    Posted Feb 12, 2018 05:22 PM

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



  • 4.  RE: how to manipulate .list() as array?

    Posted Feb 12, 2018 05:27 PM

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

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



  • 5.  RE: how to manipulate .list() as array?

    Posted Feb 13, 2018 07:48 AM

    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 :smileyhappy:
    the goal is to put all these information, with others, in a excelsheet...



  • 6.  RE: how to manipulate .list() as array?

    Posted Feb 13, 2018 08:11 AM

    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



  • 7.  RE: how to manipulate .list() as array?

    Posted Feb 14, 2018 08:11 AM

    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 :smileyhappy: