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