VMware Cloud Community
ganapa2000
Hot Shot
Hot Shot
Jump to solution

How do get Hardware Label and Status of VMnic

Hi,

How do get Hardware Label and Status of VMnic for the the below

Get-VMHostNetworkAdapter | select VMhost, Name, IP, SubnetMask, Mac, PortGroupName, vMotionEnabled, mtu, FullDuplex, BitRatePerSec | Export-Csv C:\VMHostNetworkDetails.csv

I would like to get added to the above script, marked in red

Please help

ganapa2000_0-1631627091932.png

 

0 Kudos
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

After some trial-and-error, I came up with the following, which seems to work for me.

 

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
  $esxcli = Get-EsxCli -VMHost $esx -V2
  $esxcli.hardware.pci.list.Invoke(@{class='0x200'}) |
  ForEach-Object -Process {
    [PSCustomObject]@{
      VMHost = $esxcli.VMHost.Name
      VMKernelName = $_.VMKernelName
      HardwareLabel = $_.SlotDescription
      MAC = $esxcli.network.nic.get.Invoke(@{nicname = $_.VMKernelName}).VirtualAddress
    }
  }
}

 


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

View solution in original post

0 Kudos
12 Replies
LucD
Leadership
Leadership
Jump to solution

You should be able to get that info with

$esxcli.network.nic.list.Invoke()


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

I am unable to get Hardware Label Info

Get-VMHost -Server "myhost" |
ForEach-Object -Process {
$esxcli = Get-EsxCli -VMHost $esx -V2
$esxcli.network.nic.list.Invoke() | Select *
}

ganapa2000_0-1631628971387.png

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is that screenshot earlier, coming from an ESXi console?


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Yes, screenshot is from esxi console

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Any way to get these details from cli ?

0 Kudos
LucD
Leadership
Leadership
Jump to solution

Yes, but only when you actually assigned a Hardware Label to the PCI devices.
I don't know how ESXi creates the name (for example Ethernet0) when no Hardware Label is present.


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

0 Kudos
LucD
Leadership
Leadership
Jump to solution

After some trial-and-error, I came up with the following, which seems to work for me.

 

Get-VMHost -PipelineVariable esx |
ForEach-Object -Process {
  $esxcli = Get-EsxCli -VMHost $esx -V2
  $esxcli.hardware.pci.list.Invoke(@{class='0x200'}) |
  ForEach-Object -Process {
    [PSCustomObject]@{
      VMHost = $esxcli.VMHost.Name
      VMKernelName = $_.VMKernelName
      HardwareLabel = $_.SlotDescription
      MAC = $esxcli.network.nic.get.Invoke(@{nicname = $_.VMKernelName}).VirtualAddress
    }
  }
}

 


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Thank you LucD,

Currently, I see blank for VMhost and Hardware Label

ganapa2000_0-1643961673082.png

 

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

That should have been $esxcli.VMHost.Name (code above is corrected).

Not sure if that method is valid on all vSphere versions and with all PowerCLI versions.
With PowerCLI 12.5 on a vSphere 7 platform it works for me


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

LucD,

I tried updating the PowerCLI to 12.5 but still I am seeing the Hardware Label as blank. Probably, I need to check in vSphere 7, which we currently don't have as we are using vSphere 6.7 U3, but we are upgrading to 7 shortly.

ganapa2000_0-1643977964629.png

 

0 Kudos
LucD
Leadership
Leadership
Jump to solution

It could be release-related, but it could also be HW-related.
There were other mentions of specific HW not showing values for all properties.


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

0 Kudos
ganapa2000
Hot Shot
Hot Shot
Jump to solution

Hi LucD,

As per your comments, I tried on different hardware after upgrading PowerCLI, it worked even though I am using vSphere 6.7.

You are a Champ. Thank you very much 🙂

0 Kudos