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

Advertisements

About Yuri de Jager
Technology Addict

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

  1. lio says:

    great PS1

    but i have small issue i try to upgrade it and make host list menu to choose from
    but when i press the host num his ignore my request and choose other host

    what i do wrong

    $ExportFilePath = “C:\HostVMNicsInfo.csv”
    $PuttyUser = “root”
    $PuttyPwd = “HarelEsx”
    $Plink = “C:\putty\plink.exe”
    $PlinkOptions = ” -v -pw $PuttyPwd”
    $RCommand0 = “ethtool -i “
    $ESXHosts = Get-VMHost | Sort Name

    $i = 0

    write-host -foregroundcolor Green `n “Please Choose Host”
    foreach ($ESXHosts in $ESXHosts){
    write-host -foregroundcolor Cyan “$i – $ESXHosts”
    $i++
    }
    $ESXHost = read-host `n “Enter the Host number you want to check”
    $cluster = $ESXHosts[$ESXHost]

    $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

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: