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
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
You should be able to get that info with
$esxcli.network.nic.list.Invoke()
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
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 *
}
Is that screenshot earlier, coming from an ESXi console?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, screenshot is from esxi console
Any way to get these details from cli ?
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
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
Thank you LucD,
Currently, I see blank for VMhost and Hardware Label
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
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.
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
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 🙂