I am trying to get the vendor id and device id for nic and hba adapters but why I am seeing different values when compared with $esxcli.hardware.pci.list() and esxcfg-info
Here is the script I used
$esxcli = Get-EsxCli -VMHost $esx
$nic = Get-VMHostNetworkAdapter -VMHost $esx | select -ExpandProperty Name
$hba = Get-VMHostHba -VMHost $esx -Type FibreChannel | ? { $_.Status -eq "online" } | select -ExpandProperty Name
$elxnet = $esxcli.software.vib.list() | ? { $_.name -eq "elxnet" }
$esxcli.hardware.pci.list() | ? { ($nic -contains $_.VMKernelName) -or ($hba -contains $_.VMKernelName) } | ForEach-Object -Process {
New-Object PSObject -Property (
[ordered]@{
Name = $esx.Name
Device = $_.DeviceName
VendorName = $_.VendorName
VendorID = ( $_.VendorID)
DeviceID = ($_.DeviceID)
SubVendorID = ($_.SubVendorID)
nicFWversion = ($esxcli.network.nic.get("vmnic0").driverinfo.version)
stFWversion = ($elxnet.version.substring(0, 14))
})
}
}
Output
Esxi Shell output:
The issue is that the output fields from Get-EsxCli in this case are of type [string].
And formatting a string to hex doesn't do anything.
You first have to convert the string to int.
[ordered]@{
Name = $esx.Name
Device = $_.DeviceName
VendorName = $_.VendorName
VendorID = "0x{0:x}" -f [int]$_.VendorID
DeviceID = "0x{0:x}" -f [int]$_.DeviceID
SubVendorID = "0x{0:x}" -f [int]$_.SubVendorID
nicFWversion = ($esxcli.network.nic.get("vmnic0").driverinfo.version)
stFWversion = ($elxnet.version.substring(0, 14))
})
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
The values are the same, one is displayed in decimal, the other in hex.
To display in hex format you can use the format operator
"0x{0:x}" -f ( $_.VendorID)
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
I have tried like this but its still showing incorrect value
Actual ids displayed for QLogic 10GbE 2P QMD8262-k NDC in shell are as below
Vendor Id.......................................0x1077
|----Device Id.......................................0x8020
|----Sub-Vendor Id...................................0x1028
|----Sub-Device Id...................................0x1f64
Even I am unable to find vid 0x4215 in vmware Compatibility Guide
I can able to find 0x1077 which is shown in shell prompt.
Those values are not corretc in your output.
The decimal value 4215 is hex 1077.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yeah make sense. Is there any way if i can display the values in Hexadecimal format.
The issue is that the output fields from Get-EsxCli in this case are of type [string].
And formatting a string to hex doesn't do anything.
You first have to convert the string to int.
[ordered]@{
Name = $esx.Name
Device = $_.DeviceName
VendorName = $_.VendorName
VendorID = "0x{0:x}" -f [int]$_.VendorID
DeviceID = "0x{0:x}" -f [int]$_.DeviceID
SubVendorID = "0x{0:x}" -f [int]$_.SubVendorID
nicFWversion = ($esxcli.network.nic.get("vmnic0").driverinfo.version)
stFWversion = ($elxnet.version.substring(0, 14))
})
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks this worked
I added firmware variable and when I run the script
New-Object PSObject -Property (
[ordered]@{
HostName = $esx.Name
Device = $_.DeviceName
VendorName = $_.VendorName
VendorID = "{0:x}" -f [int]$_.VendorID
DeviceID = "{0:x}" -f [int]$_.DeviceID
SubVendorID = "{0:x}" -f [int]$_.SubVendorID
nicFWversion = ($esxcli.network.nic.get("vmnic0").driverinfo.version)
stFWversion = ($elxnet.version.substring(0, 14))
driver = $NetworDriver.Version
firmware = $NetworkFirmware
devicename = $NetworkName
I get this output
How can I get SDID? And why do I get "vmnic5" as device name for all devices?
Device names should be vmnic0,vmnic1, vmnic2, vmnic3, vmnic4, vmnic5, vmhba0, vmhba1
You use the variable $NetworkName, which I suspect contains 'vmnic5'.
Since you didn't post your complete script, I can't see why you would use that variable.
The object also contains a propertySubDeviceId, which is the SDID
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
This is the whole script
foreach ($esx in Get-VMHost | ? { $_.ConnectionState -eq 'Connected' }) {
$esxcli = Get-EsxCli -VMHost $esx
$nic = Get-VMHostNetworkAdapter -VMHost $esx | select -ExpandProperty Name
$hba = Get-VMHostHba -VMHost $esx -Type FibreChannel | ? { $_.Status -eq "online" } | select -ExpandProperty Name
$elxnet = $esxcli.software.vib.list() | ? { $_.name -eq "elxnet" }
$esxcli.hardware.pci.list() | ? { ($nic -contains $_.VMKernelName) -or ($hba -contains $_.VMKernelName) } | ForEach-Object -Process {
New-Object PSObject -Property (
[ordered]@{
HostName = $esx.Name
Device = $_.DeviceName
VendorName = $_.VendorName
VendorID = "{0:x}" -f [int]$_.VendorID
DeviceID = "{0:x}" -f [int]$_.DeviceID
SubVendorID = "{0:x}" -f [int]$_.SubVendorID
nicFWversion = ($esxcli.network.nic.get("vmnic0").driverinfo.version)
stFWversion = ($elxnet.version.substring(0, 14))
driver = $NetworDriver.Version
firmware = $NetworkFirmware
devicename = $NetworkName
})
}| Export-Csv -Path 'C:\ESXI HBA & NIC info.csv'
}
I used $NetworkName from here https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Get-HBA-firmware-and-driver-version-fo...
I have only this variables
VendorID = "{0:x}" -f [int]$_.VendorID
DeviceID = "{0:x}" -f [int]$_.DeviceID
SubVendorID = "{0:x}" -f [int]$_.SubVendorID
but don't have SubDeviceID in script. I've tried to add it in this form "SubDeviceID = "{0:x}" -f [int]$_.SubDeviceID" but didn't work.
Try this way.
$vmhosts = Get-VMHost
$report = @()
foreach ($ESXHost in $vmhosts) {
$esxcli = Get-EsxCli -VMHost $ESXHost -V2
$nicfirmware = $esxcli.network.nic.list.Invoke()
$fcfirmware = $esxcli.storage.san.fc.list.Invoke()
$driversoft = $esxcli.software.vib.list.Invoke()
foreach ($nicfirmwareselect in $nicfirmware) {
$NetworDescription = $nicfirmwareselect.Description
$NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
$NetworkName = $nicfirmwareselect.Name
$NetworkFirmware = $esxcli.network.nic.get.Invoke(@{nicname=$nicfirmwareselect.Name}).DriverInfo.FirmwareVersion
$ids = $esxcli.hardware.pci.list.Invoke() | where{$_.VMKernelName -eq $NetworkName}
$report += "" |
select @{N = "Hostname"; E = { $ESXHost.Name } },
@{N = "Hardware-Model"; E = { $ESXHost.Model } },
@{N = "device"; E = { $NetworkName } },
@{N = "driver"; E = { $NetworDriver.Version } },
@{N = "firmware"; E = { $NetworkFirmware } },
@{N = "description"; E = { $NetworDescription } },
@{N='VendorID';E={"{0:x}" -f [int]$ids.VendorID}},
@{N='DeviceID';E={"{0:x}" -f [int]$ids.DeviceID}},
@{N='SubVendorID';E={"{0:x}" -f [int]$ids.SubVendorID}},
@{N='SubDeviceId';E={"{0:x}" -f [int]$ids.SubDeviceID}}
}
foreach ($fcfirmwareselect in $fcfirmware) {
$fcDescription = $fcfirmwareselect.ModelDescription
$fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
$fcName = $fcfirmwareselect.Adapter
$fcFirmware = $fcfirmwareselect.FirmwareVersion
$ids = $esxcli.hardware.pci.list.Invoke() | where{$_.VMKernelName -eq $fcName}
$report += "" |
select @{N = "Hostname"; E = { $ESXHost.Name } },
@{N = "Hardware-Model"; E = { $ESXHost.Model } },
@{N = "device"; E = { $fcName } },
@{N = "driver"; E = { $fcDriver.Version } },
@{N = "firmware"; E = { $fcFirmware } },
@{N = "description"; E = { $fcDescription } },
@{N='VendorID';E={"{0:x}" -f [int]$ids.VendorID}},
@{N='DeviceID';E={"{0:x}" -f [int]$ids.DeviceID}},
@{N='SubVendorID';E={"{0:x}" -f [int]$ids.SubVendorID}},
@{N='SubDeviceId';E={"{0:x}" -f [int]$ids.SubDeviceID}}
}
}
$report | Export-Csv -Path 'C:\ESXI HBA & NIC info.csv'
PS: next time don't piggy-back on existing threads with new requirements, but rather create a new thread.
That allows other users to more easily find such questions.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
That's it, that's what I need, thank you!
Just one more thing, do you know why it won't list VID,DID,SVID & SDID for hba's?
Sorry for piggy-backing on existing threads, I thought it would be better to reply to the similar thread then opening a new one.
Won't happen again 🙂
I suspect my type ($fckName instead $fcName) caused that.
I updated the code above.
No problem, you can always include a link to the original post for which you have an additional requirement
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Yes, now it works like a charm!
Thank you once again!
Hi @LucD
Looking to update the script to pull the hba/firmware details on a vSAN environment and when I update the string '$esxcli.storage.san.sas.list.Invoke()' to use sas it still doesn't pull any information on the hosts. Is there an additional switch I'm missing here?
$vmhosts = Get-VMHost
$report = @()
foreach ($ESXHost in $vmhosts) {
$esxcli = Get-EsxCli -VMHost $ESXHost -V2
$nicfirmware = $esxcli.network.nic.list.Invoke()
$fcfirmware = $esxcli.storage.san.sas.list.Invoke()
$driversoft = $esxcli.software.vib.list.Invoke()
Thanks in advance
Have a look in Jase's POWERCLI COOKBOOK FOR VMWARE VSAN?
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Hi LucD - nothing in the cookbook relating to hba firmware or any firmware specific commands on a vSAN environment.
Running 'esxcli storage san sas list' gets the relevant details for the f/w and driver version so just looking to pull this via a script then.
Hi @LucD
I'm using the following script to get the HBA details now however it fails to pull the firmware version on 'lsi_msgpt3' driver types. Is this a switch I'm missing to collect this information?
$vcenter = "vctest"
Connect-VIServer $vcenter
$vmhosts = Get-VMHost | Where {$_.Connectionstate -eq "Connected"}
$reportHba = @()
foreach ($vmhost in $vmhosts){
$esxcli = Get-EsxCli -VMHost $vmhost -V2
$reportHba += $esxcli.Storage.san.sas.list.Invoke()|
select @{N = 'HostName'; E = {$esxcli.VMHost.Name}},
DeviceName, DriverName, DriverVersion, FirmwareVersion
}
$reportHba | Export-Csv -Path 'S:\Scripts\Hbainfo.csv' -NoTypeInformation -UseCulture
Sample output included below where you can see the driver version pulled successfully for llsi_mr3 but no info. displayed for :lsi_msgpt3
HostName : server1
DeviceName : vmhba0
DriverName : lsi_msgpt3
DriverVersion : 16.00.01.00
FirmwareVersion :
HostName : server2
DeviceName : vmhba0
DriverName : lsi_mr3
DriverVersion : 7.708.07.00
FirmwareVersion : 25.5.7.0005
Any advice would be appreciated.
Hi LucD,
This script worked great on HP esxi hosts.
Now I have Dell hosts and some fields are blank, can you tell me why?
This is a known issue for some HW vendors and some of their specific HW types.
Best course of action would be to contact your HW vendor.
It might be a VIB missing or an incorrect version.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference