Home > ESX, Flex-10, HP, PowerCLI, Powershell, VMware > Getting Nic firmware versions with PowerCLI

Getting Nic firmware versions with PowerCLI

Sometimes you need to delve into the innards of ESX to get information out that just isn’t available through the VMware SDK and so not directly available to PowerCLI.

If you’ve been doing any work recently with HP Flex-10 and its firmware requirements, you may need to find out the network card firmware version which is only available from within the ESX console by typing ethtool -i vmnic0

So, PowerCLI to the rescue, but actually using PowerCLI to call Plink.exe which is Putty’s command-line connection tool. You can use this same process to pull anything that you can get from the ESX console as long as you can parse the results of the command and find the information you need.

I’ve used PowerCLI to get some other information about the hosts to make it into a more useful report for a larger environment which you can remove from the hash table if you just need the firmware versions.

When using Get-VMHost I’ve used a filter to get only hosts with a model name of “Proliant BL” which returns the relevant HP blades. This can also be amended to either get all hosts or use any other filter you may need.

The information returned from Putty is a text array of strings so you can use any string handling commands to get at the information you need.

$ExportFilePath = "C:\HostNicInfo.csv"
$PuttyUser = "root"
$PuttyPwd = "password"
$HostNic = "vmnic0"
$Plink = "C:\Progra~1\PuTTY\plink.exe"
$PlinkOptions = " -v -batch -pw $PuttyPwd"
$RCommand = '"' + "ethtool -i " + $HostNic + '"'

$ESXHosts = Get-VMHost | where {$_.Model -match "ProLiant BL*"} | Sort Name

$Report = @()
ForEach ($ESXHost in $ESXHosts) {
		$Message = ""
		$HostInfo = {} | Select HostName,ESXVersion,Cluster,pNic,DriverName,DriverVersion,DriverFirmware
		$HostInfo.HostName = $ESXHost.Name
		$HostInfo.ESXVersion = $ESXHost.Version
		$HostInfo.Cluster = (Get-Cluster -VMHost $ESXHost.Name).Name
		$HostInfo.pNic = $HostNic
		Write-Host "Connecting to: " $ESXHost.Name -ForegroundColor Green
		$Command = $Plink + " " + $PlinkOptions + " " + $PuttyUser + "@" + $ESXHost.Name + " " + $rcommand
		$Message = Invoke-Expression -command $command
		$HostInfo.DriverName = ($Message[0] -split "driver: ")[1]
		$HostInfo.DriverVersion = ($Message[1] -split "version: ")[1]
		$HostInfo.DriverFirmware = ($Message[2] -split "firmware-version: ")[1]
		$Report += $HostInfo
}
$Report = $Report | Sort-Object HostName
IF ($Report -ne "") {
$Report | Export-Csv $ExportFilePath -NoTypeInformation
}
Invoke-Item $ExportFilePath
  1. Nicky
    July 11th, 2011 at 11:07 | #1

    Hey, this is a good one. This only takes ourput for one vmnic at a time. Can this be modified to take all nics at once.

    Thanks..

  2. albertwt
    September 23rd, 2013 at 23:23 | #2

    I couldn’t access the Blade on port 22, does this means that I must specifically enable SSH on all of the ESXi server blades ?

  3. evan
    August 25th, 2016 at 15:22 | #3

    Hey Julian,

    I know that this is an old post but I was hoping you could help me out with something.

    I am using this script and it is working fine however we have a number of HP hosts in the environment which don’t respond to the ethtool -i command. I have replaced the command with “esxcli network nic get -n vmnic0” and I changed the $Message split commands to reflect the correct fields I am trying to capture but it does not seem to be working. I’m thinking that I’m not getting a match because the Driver, Firmware, and Version is nested below “Driver Info” in the output.

    Any help would be greatly appreciated.

  1. March 2nd, 2011 at 11:39 | #1
 

Time limit is exhausted. Please reload the CAPTCHA.