2 Replies Latest reply on Aug 19, 2019 8:10 PM by AlbertWT

    Unable to pull the information of ESXi server IPAddress, Manufacturer, ProcessorType, BIOS version, HBA Model and Driver ?

    AlbertWT Master

      Hi All,

       

      I need to get some hardware and driver, firmware information using the below PowerCLI, however, some of the columns in the.CSV file is not working like below are empty:

      IPAddressManufacturerProcessorTypeBIOS versionHBA ModelDriver

       

      This is the code I am using:

      $ResultFile = "C:\Result.CSV"

       

      $vmhosts = Get-Datacenter | Get-VMHost

      $report = @()

      foreach( $ESXHost in $vmhosts) {


         $HWModel = Get-VMHost $ESXHost

         $esxcli = Get-EsxCli -vmhost $ESXHost

         $info = $esxcli.network.nic.get("vmnic0")

         $elxnet = $esxcli.software.vib.list() | Where-Object { $_.name -eq "elxnet"}

         $lpfc = $esxcli.system.module.list() | Where-Object {$_.Name -eq '*'}

         if($lpfc){

         $lpfc = $esxcli.system.module.get("*")

        }

             

         $report += $info |


         Select-Object @{N="Hostname"; E={$ESXHost.Name}},

         @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}},

        Manufacturer, 

        ProcessorType,

         @{N="BIOS version";E={$_.ExtensionData.Hardware.BiosInfo.BiosVersion}}, 

         @{N="Hardware-Model"; E={$HWModel.Model}},

         @{N="Adapter-Firmware"; E={$_.DriverInfo.FirmwareVersion}},

         @{N="Network-Driver"; E={$_.DriverInfo.Version}},

         @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}},

         @{N="HBA Model";E={($_ | get-vmhosthba | select-object -ExpandProperty Model) -join ", "}}, 

         @{N="Driver";E={($_ | get-vmhosthba | select-object -ExpandProperty Driver) -join ", "}}

         @{N='HBA-Module';E={$lpfc.Module}},

         @{N='HBA-Version';E={$lpfc.Version}}

      }

      $report | Export-Csv -Path $ResultFile -NoTypeInformation

      ii $ResultFile

       

      There is no error in the console session:

       

      Name                           Value

      ----                           -----

      N                              HBA-Module

      E                              $lpfc.Module

      N                              HBA-Version

      E                              $lpfc.Version

      N                              HBA-Module

      E                              $lpfc.Module

      N                              HBA-Version

      E                              $lpfc.Version

       

      Thank you in advance.

        • 1. Re: Unable to pull the information of ESXi server IPAddress, Manufacturer, ProcessorType, BIOS version, HBA Model and Driver ?
          LucD Guru
          User ModeratorsCommunity WarriorsvExpert

          The funny property names is due to the comma that is missing at a line in the Select.
          Also the properties should be derived from the $ESXHost object, only the Firmware and Driver comes from the $info object.

          Try like this

           

          $ResultFile = "C:\Result.CSV"

          $vmhosts = Get-Datacenter | Get-VMHost

          $report = @()

          foreach ( $ESXHost in $vmhosts)

          {

             $HWModel = Get-VMHost $ESXHost

             $esxcli = Get-EsxCli -vmhost $ESXHost

             $info = $esxcli.network.nic.get("vmnic0")

             $elxnet = $esxcli.software.vib.list() | Where-Object { $_.name -eq "elxnet" }

             $lpfc = $esxcli.system.module.list() | Where-Object { $_.Name -eq '*' }

             if ($lpfc)

             {

             $lpfc = $esxcli.system.module.get("*")

             }


             $report += $ESXHost |

             Select-Object @{N = "Hostname"; E = { $_.Name } },

             @{N = "IPAddress"; E = { ($_ | Get-VMHostNetwork).VirtualNic | Where-Object { $_.ManagementTrafficEnabled } | Select-Object -ExpandProperty IP } },

            Manufacturer,

            ProcessorType,

             @{N = "BIOS version"; E = { $_.ExtensionData.Hardware.BiosInfo.BiosVersion } },

             @{N = "Hardware-Model"; E = { $HWModel.Model } },

             @{N = "Adapter-Firmware"; E = { $info.DriverInfo.FirmwareVersion } },

             @{N = "Network-Driver"; E = { $info.DriverInfo.Version } },

             @{N = "FC-Driver"; E = { $elxnet.version.substring(0, 14) } },

             @{N = "HBA Model"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Model) -join ", " } },

             @{N = "Driver"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Driver) -join ", " } },

             @{N = 'HBA-Module'; E = { $lpfc.Module } },

             @{N = 'HBA-Version'; E = { $lpfc.Version } }

          }

          $report | Export-Csv -Path $ResultFile -NoTypeInformation

          1 person found this helpful