This Blog is to share our knowledge and expertise on Linux System Administration and VMware Administration

Thursday, September 14, 2017

Getting ESXi Network driver firmware details by using Script.

Find the script as follows.

$ExportFilePath = "C:\Users\user\Desktop\esxi.txt"
$PuttyUser = "root"
$PuttyPwd = "w2k8the$"
$HostNic = "vmnic0,vmnic1"
$Plink = "C:\Users\user\Desktop\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

No comments:

Post a Comment