VMware Cloud Community
Aldo_patrick
Contributor
Contributor
Jump to solution

ESX BIOS, NIC and HBA Driver Versions

Hi friends,

am intermiediate user of POWERCLI and shell scritping,please colud any help me to run below script.

more info  http://www.sandfordit.com/vwiki/ESX_Script_Extracts_and_Examples

Thanks in advance,

Aldo.

Getting BIOS, NIC and HBA driver versions is dependant on what's reported to the ESX by the hardware vendor's CIM provider. This script was written using various HP servers and may well only work for them.

# ===============================================================
# ESX Inventory Getter
# ===============================================================
# Simon Strutt        November 2010
# ===============================================================
#
# Version 1
# - Initial Creation
#
# Version 2 - Dec 2010
# - Added BiosVer, CpuCores, CpuModel, HbaModel, NicModel
# - Bugfix: Corrected VC connection handling
# - Removed dependency on obsoleted properties (from upgrade to PowerCLI v4.1.1)
#
# Limitations
# - Tested on HP DL380 (G7), BL465 (G7), BL495 (G6), BL685 (G5)
# - Supports 1 distinct HBA model, 2 distinct NIC models
#
# ================================================================
 
$start = Get-Date
$OutputFile = "ESXs.csv"
$VC_List = "ESX-Check.csv"
$UserFile = "User.fil"
$PassFile = "Pass.fil"                           # Encrypted file to store password in
$Results = @()
 
# Include library files
. .\lib\Standard.ps1
 
Start-Transcript -Path ESX-Inventory.log
Log "Started script run at $start"
 
# Function-U-like ===================================================================================
 
Function Get-NicDriverVersion ($view, $driver) {
    # Gets the CIM provided driver version (tallies up driver name with CIM software component)
    $result = ($view.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | Where {$_.Name -like $driver + " driver*"} | Get-Unique).Name
    $result = ([regex]::Matches($result, "(\b\d)(.*)(?=\s)"))[0].Value         # HP regex to extract "2.102.440.0" for example
    $result
}
 
# =================================================================================================== 
 
# Load list of VC's
try {
    $VCs = Import-CSV $VC_List
} catch {
    Log "ERROR: Failed to load list of vC's"
    Exit
}
 
# Load password credential from encrypted file
$pass = Get-Content $PassFile | ConvertTo-SecureString
$user = Get-Content $UserFile
$cred = New-Object System.Management.Automation.PsCredential($user, $pass)
 
foreach ($vc in $VCs) {
 
    # Connect to VC
    try {
        Log("Connecting to " + $vc.vc)
        $VCconn = Connect-VIServer -Server $vc.vc -Credential $cred -errorAction "Stop"
    } catch [VMware.VimAutomation.ViCore.Types.V1.ErrorHandling.InvalidLogin] {
        Log("Unable to connect to vCentre, invalid logon error !!")
        Log("Abandoning further script processing in order to prevent potential account lockout.")
        Break
    } catch {
        Log("Unable to connect to vCentre - " + $_)
        Continue
    }
 
    # Get ESX objects
    Log("Getting list of ESXs to check on " + ($vc.vc) + "...")
    $ESXs = Get-VMHost -Server $vc.vc | Sort -property Name
    Log("Got list of " + ($ESXs.Count) + " ESXs to check") 
 
    ForEach ($ESX in $ESXs) {
        $row = "" | Select VC, Cluster, Name, IP, Version, Make, Model, BiosVer, CpuCores, CpuModel, HbaModel, HbaDriver, HbaDriverVer, Nic1Model, Nic1Driver, Nic1DriverVer, Nic2Model, Nic2Driver, Nic2DriverVer
        Log($ESX.Name)
 
        # Store objects which get re-used for efficiency
        $ESXview = Get-View -VIObject $ESX
        $VMHostNetworkAdapter = Get-VMHostNetworkAdapter -VMHost $esx 
 
        # Get the basics
        $row.VC = $vc.vc
        $row.Cluster = $ESX.Parent
        $row.Name = $ESX.Name.Split(".")[0]
        $row.IP =  ($VMHostNetworkAdapter | Where {$_.ManagementTrafficEnabled -eq "True" -or $_.DeviceName -like "vswif*" -or $_.Name -eq "vmk0"}).IP
        $row.Version = $ESX.Version + " (" + $ESX.Build + ")"
        $row.Make = $ESX.Manufacturer
        $row.Model = $ESX.Model
 
        # Now onto the more ESX version / hardware specific stuff (new versions of hardware will require further work below)
 
        # BIOS
        if ($ESXView.Hardware.BiosInfo) {     # Works on some systems 
            $row.BiosVer = $ESXview.Hardware.BiosInfo.BiosVersion + " " + $ESXview.Hardware.BiosInfo.ReleaseDate.ToString("yyyy-MM-dd")   # Need date for HP servers as they use same version no for diff versions!
        } else {
            $row.BiosVer = ($ESXview.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | Where {$_.Name -like "*BIOS*"}).Name
            $row.BiosVer = ([regex]::Matches($row.BiosVer, "[A-Z]\d{2} 20\d{2}-\d{2}-\d{2}"))[0].Value           # HP regex to extract "A19 2010-09-30" for example
        }
 
        # CPU info
        $row.CpuCores = $ESXview.Hardware.CpuInfo.NumCpuCores.ToString() + " (" + $ESXview.Hardware.CpuPkg.count + "x" + $ESXview.Hardware.CpuPkg[0].ThreadId.count + ")"
        $row.CpuModel = $ESX.ExtensionData.Summary.Hardware.CpuModel
 
        # HBA info (script assumes only one HBA model in use)
        $row.HbaModel = ($ESX.ExtensionData.Config.StorageDevice.HostBusAdapter | Where {$_.Key -like "*FibreChannel*"})[0].Model
        $row.HbaDriver = ($ESX.ExtensionData.Config.StorageDevice.HostBusAdapter | Where {$_.Key -like "*FibreChannel*"})[0].Driver     # Includes version for ESX3
        $row.HbaDriverVer = ($ESXview.Runtime.HealthSystemRuntime.SystemHealthInfo.NumericSensorInfo | Where {$_.Name -like "*" + $row.HbaDriver + "*"}).Name
        $row.HbaDriverVer = ([regex]::Matches($row.HbaDriverVer, "(\b\d)(.*?)(?=\s)"))[0].Value
 
        # NIC info (script only supports two distinct NIC types)
        $nics = $ESXview.Hardware.PciDevice | Where {$_.ClassId -eq 512} | Select VendorName, DeviceName, Id | Sort-Object -Property DeviceName -Unique
        if ($nics.count) {
            $row.Nic1Model = $nics[0].VendorName + " " + $nics[0].Devicename
            $row.Nic2Model = $nics[1].VendorName + " " + $nics[1].Devicename
 
            # Use PCI ID to match up NIC hardware type with driver name
            $row.Nic1Driver = ($VMHostNetworkAdapter | Where {$_.ExtensionData.Pci -eq $nics[0].Id}).ExtensionData.Driver
            $row.Nic2Driver = ($VMHostNetworkAdapter | Where {$_.ExtensionData.Pci -eq $nics[1].Id}).ExtensionData.Driver
 
            $row.Nic1DriverVer = Get-NicDriverVersion $ESXview $row.Nic1Driver
            $row.Nic2DriverVer = Get-NicDriverVersion $ESXview $row.Nic2Driver
         } else {
            # Annoyingly, $nics is not an array if there's only one NIC type, hence seperate handling
            $row.Nic1Model = $nics.VendorName + " " + $nics.Devicename
            $row.Nic1Driver = ($VMHostNetworkAdapter | Where {$_.ExtensionData.Pci -eq $nics.Id}).ExtensionData.Driver
            $row.Nic1DriverVer = Get-NicDriverVersion $ESXview $row.Nic1Driver
        }
 
        $Results = $Results + $row
    }
    Disconnect-VIServer -Server $VCconn -Confirm:$false
}
$Results | Format-Table *
Log("Writing results to $OutputFile...")
$Results | Export-Csv -path $OutputFile -NoTypeInformation
 
Log("All completed")
Stop-Transcript
Reply
0 Kudos
1 Solution

Accepted Solutions
SimonStrutt
Enthusiast
Enthusiast
Jump to solution

Hi Aldo,

As per the PM I sent you, I've genericised the script a bit more so it should be easier to use (no need for the Standard.ps1 file).  Similarly the name(s) of your Virtual Centre servers don't need to be put into a seperate CSV file either

To avoid having to create credentials files, delete the following lines...

# Load password credential from encrypted file            
$pass = Get-Content $PassFile | ConvertTo-SecureString            
$user = Get-Content $UserFile            
$cred = New-Object System.Management.Automation.PsCredential($user, $pass)

...and replace with (the script will prompt you for user/pass)...

$cred = Get-Credential

Hope that gets you up and running.

Note that I've found getting NIC and HBA driver versions is fairly unreliable using that script, as there's not much consistency in what is returned by CIM from the hardware providers.  Plus on the servers I've tested with, HBA firmware was never available.  A more reliable, but more involved method is to use PowerShell to SSH to your ESX's, this has its own problems, but is another approach (when doing system audits I tend to use both).  See below for further info...

http://vblog.strutt.org.uk/2012/04/esx-hba-and-nic-driverfirmware-versions/

All the best...

Simon

"The greatest challenge to any thinker is stating the problem in a way that will allow a solution." - Bertrand Russell

View solution in original post

Reply
0 Kudos
4 Replies
LucD
Leadership
Leadership
Jump to solution

Do you have the lib\Standard.ps1 file that is dot-sourced at the beginning ?

You will also need to set up the credential file to connect to the vCenters.

The vCenters you want to check should be in a CSV file that look like this

VC

vCenter1

vCenter2


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

Aldo_patrick
Contributor
Contributor
Jump to solution

Hi Lucd,

Thanks for prompt answer..sry to say..I dont have  the lib\Standard.ps1 File.

I got the above script from http://www.sandfordit.com/vwiki/ESX_Script_Extracts_and_Examples

,This script is very helpful to reach my goal.

please feel free,colud you modify the script to run the script and get the information.I dont want to be use same script,

Thanks in advance

Aldo.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

I suspect this is the standard.ps1 file.


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

Reply
0 Kudos
SimonStrutt
Enthusiast
Enthusiast
Jump to solution

Hi Aldo,

As per the PM I sent you, I've genericised the script a bit more so it should be easier to use (no need for the Standard.ps1 file).  Similarly the name(s) of your Virtual Centre servers don't need to be put into a seperate CSV file either

To avoid having to create credentials files, delete the following lines...

# Load password credential from encrypted file            
$pass = Get-Content $PassFile | ConvertTo-SecureString            
$user = Get-Content $UserFile            
$cred = New-Object System.Management.Automation.PsCredential($user, $pass)

...and replace with (the script will prompt you for user/pass)...

$cred = Get-Credential

Hope that gets you up and running.

Note that I've found getting NIC and HBA driver versions is fairly unreliable using that script, as there's not much consistency in what is returned by CIM from the hardware providers.  Plus on the servers I've tested with, HBA firmware was never available.  A more reliable, but more involved method is to use PowerShell to SSH to your ESX's, this has its own problems, but is another approach (when doing system audits I tend to use both).  See below for further info...

http://vblog.strutt.org.uk/2012/04/esx-hba-and-nic-driverfirmware-versions/

All the best...

Simon

"The greatest challenge to any thinker is stating the problem in a way that will allow a solution." - Bertrand Russell
Reply
0 Kudos