PowerCLI

 View Only
Expand all | Collapse all

Finding VID, DID & SVID from PCI devices in ESXi

Vineeth_K

Vineeth_KDec 16, 2019 11:53 AM

  • 1.  Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 10:43 AM

    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

    foreach ($esx in Get-VMHost 'sez00wtr-0625.sweng.ncr.com'| ? { $_.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]@{

                    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:



  • 2.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 10:46 AM

    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)



  • 3.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 11:07 AM

    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.



  • 4.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 11:17 AM

    Those values are not corretc in your output.
    The decimal value 4215 is hex 1077.



  • 5.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 11:23 AM

    Yeah make sense. Is there any way if i can display the values in Hexadecimal format.



  • 6.  RE: Finding VID, DID & SVID from PCI devices in ESXi
    Best Answer

    Posted Dec 16, 2019 11:48 AM

    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.

    New-Object PSObject -Property (

        [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))

        })



  • 7.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Dec 16, 2019 11:53 AM

    Thanks this worked:smileyhappy:



  • 8.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 03:37 PM

    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 

    esx.JPG

    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



  • 9.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 03:55 PM

    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



  • 10.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 04:25 PM

    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.



  • 11.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 05:02 PM

    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.



  • 12.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 06:10 PM

    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?

     

    esx.JPG

    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



  • 13.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 06:19 PM

    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



  • 14.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Mar 23, 2021 06:33 PM

    Yes, now it works like a charm!

    Thank you once again!



  • 15.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Aug 06, 2021 01:02 PM

    Hi  

    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



  • 16.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Aug 06, 2021 03:16 PM

    Have a look in Jase's POWERCLI COOKBOOK FOR VMWARE VSAN?



  • 17.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Aug 09, 2021 01:36 PM

    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.



  • 18.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Aug 11, 2021 10:56 AM

    Hi  

    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.



  • 19.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted May 03, 2023 08:53 AM

    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?

    HrcoCro_1-1683103943036.png

     



  • 20.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted May 03, 2023 09:14 AM

    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.



  • 21.  RE: Finding VID, DID & SVID from PCI devices in ESXi

    Posted Oct 06, 2023 12:09 PM

    It seems a problem with the powershell command. If you use 'esxcli hardware pci list' at the host the output is correct:

    0000:1b:00.0
    Address: 0000:1b:00.0
    Segment: 0x0000
    Bus: 0x1b
    Slot: 0x00
    Function: 0x0
    Vendor Name: VMware Inc.
    Device Name: vmxnet3 Virtual Ethernet Controller
    Configured Owner: VMkernel
    Current Owner: VMkernel
    Vendor ID: 0x15ad
    Device ID: 0x07b0
    SubVendor ID: 0x15ad
    SubDevice ID: 0x07b0
    Device Class: 0x0200

    In the csv the fields are empty :

    "R750 vSAN Ready Node","vmnic0","4.1.13.0-4vmw.802.0.0.22380479","bc 1.39 ncsi 1.5.42.0","Broadcom Corporation NetXtreme BCM5720 Gigabit Ethernet","0","0","0","0"