VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

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

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.

/* Please feel free to provide any comments or input you may have. */
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

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

---------------------------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

View solution in original post

2 Replies
LucD
Leadership
Leadership
Jump to solution

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

---------------------------------------------------------------------------------------------------------------------------

Was it helpful? Let us know by completing this short survey here.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Many thanks, Luc, you're always be very helpful.

/* Please feel free to provide any comments or input you may have. */
0 Kudos