List all physical NIC’s driver and firmware information of all your ESXi 4.1 hosts using PowerCLI 4.1

Using the following script (an edited version of Julian Wood’s script), I was able to create a report of all firmware and drivers of the physical NICs in our ESXi hosts. Please note you need plink.exe because the info can only be extracted at the host level.

$ExportFilePath = “C:\HostVMNicsInfo.csv”
$PuttyUser = “root”
$PuttyPwd = “password”
$Plink = “D:\plink.exe”
$PlinkOptions = ” -v -pw $PuttyPwd”
$RCommand0 = “ethtool -i ”

$ESXHosts = Get-VMHost | Sort Name

$Report = @()
ForEach ($ESXHost in $ESXHosts) {
$pNics = $ESXHost | Get-VMHostNetworkAdapter -physical
ForEach ($pNic in $pNics) {
$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 = $pNic.Name
Write-Host “Connecting to: ” $ESXHost.Name -ForegroundColor Green
$Command = $Plink + ” ” + $PlinkOptions + ” ” + $PuttyUser + “@” + $ESXHost.Name + ” ” + $RCommand0 + ” ” + $pNic.Name
$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

To enable/disable the TSM-SSH service on each host, I used the excellent hostServiceManagement.pl script by William Lam from the vMA.

./hostServiceManagement.pl –server vc.your.domain –hostfile all_esxi_hosts –operation start –service TSM-SSH

./hostServiceManagement.pl –server vc.your.domain –hostfile all_esxi_hosts –operation stop –service TSM-SSH