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-for-all-ESXi-hosts/m-p/1760457#M55836
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.