PowerCLI

 View Only
  • 1.  Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 03:18 PM

    Hello!

    i have a little power cli script

    Get-VMHostNetworkAdapter | Select VMHost, Name

    and i wont to add information of network card model.

    See on screenshot!

    What i need to add in my script ?

    Thanks!



  • 2.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 03:42 PM

    Hi,

    I don't think Get-VMHostNetworkAdapter can give you this information.

    You can get it by using Get-EsxCli though:

    (Get-EsxCli -VMHost VMHOSTNAME).network.nic.list() | Select Name, Description

    Tim



  • 3.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 03:46 PM

    Thanks!

    but i have many hosts and many clusters in one Vcenter

    I need a script, like this

    hostname-datacentername-clustername-nameofnetworkcard(vmnic0 etc)-modelofnetworkcard



  • 4.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 03:57 PM

    No problem.

    I'm sure it can be done way more efficient, but quick and dirty:

    foreach ($h in (Get-Vmhost)){(Get-EsxCli -VMHost $h).network.nic.list() | Select @{N="Host";E={$h}},@{N="DataCenter";E={$h | Get-DataCenter}},@{N="Cluster";E={$h | Get-Cluster}},Name, Description | ft}

    Tim



  • 5.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 08:05 PM

    Many thanks my friends!

    and finally, can you help me about export this information in csv file,

    Whis wondeful for me and i save many time, becouse i have 300 hosts and 100 clusters...



  • 6.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 11, 2015 07:31 AM

    scheppTim Scheppeit

    script good, but datacenter not visible in list!



  • 7.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 16, 2015 08:06 AM

    Thanks again!

    and need help again)

    help with script to export hba adapters from vcenter server

    thanks



  • 8.  RE: Get-VMHostNetworkAdapter and model of Network Card

    Posted Mar 10, 2015 03:57 PM

    Looks like you may have to use the Get-EsxCli cmdlet to get that information.

    Here's what I would do.  You already have your list of host and network adapters (I would also specify "-Physical" on Get-VMHostNetworkAdapters to eliminate the VMkernel adapters).

    $nic_info = Get-VMHostNetworkAdapter -Physical | Select VMHost, Name

    $nic_collection = @()

    foreach ($nic in $nic_info)

    {

         $esxcli_cmd = Get-EsxCli -VMHost $nic.VMHost

         $collect_info = "" | Select VMHost, vmnic, Description

         $collect_info.VMHost = $nic.VMHost

         $collect_info.vmnic  = $nic.Name

         $collect_info.Description = ($esxcli.network.nic.list() | where {$_.Name -match $nic.Name}).Description

         $nic_collection += $collect_info

    }

    Write-Host $nic_collection