Link to home
Start Free TrialLog in
Avatar of JB Blanco
JB BlancoFlag for United States of America

asked on

Need a PowerCLI Script to get Driver and Firmware info For VSAN Hosts

Need a PowerCLI Script that will do the following:

1.) Scan all the ESXi Hosts that are part of a VSAN Cluster in my Vcenter

2.) Get Only the Driver & Firmware information for the smartpqi Module

Module = smartpqi

Driver Version:

Firmware Version:

Driver Version:


3.) Display the results for each ESXi Host

4.) Optional - Maybe export the info to excel spreadsheet

Thanks  Really appreciate this!
Avatar of Murali Sripada
Murali Sripada

Try this Blanco:

Get-Datacenter -Name "*" | Get-VMHost -PipelineVariable esx |
    ForEach-Object -Process {
    $esxcli = Get-EsxCli -VMHost $_ -V2
    $esxcli.network.nic.list.Invoke() |
        Where-Object {$_.Name -match "^vmnic"} |
        ForEach-Object -Process {
        $nic = $_
        $esxcli.network.nic.get.Invoke(@{nicname = $_.Name}).DriverInfo |
            ForEach-Object -Process {
            [PSCustomObject]@{
                VMHost   = $esx.Name
                Nic      = $nic.Name
                Driver   = $_.Driver
                Version  = $_.Version
                Firmware = $_.FirmwareVersion
            }
        }
    }
} | Export-Csv -Path C:\RESULT\pNIC.csv -NoTypeInformation

Open in new window


or this one if it is does not working:

$ResultFile = "C:\TEMP\Result.CSV"
$vmhosts = Get-Datacenter -Name '*' | Get-VMHost
$report = @()

foreach ( $ESXHost in $vmhosts) {

    $HWModel = Get-VMHost $ESXHost
    $esxcli = Get-EsxCli -vmhost $ESXHost
    $info = $esxcli.network.nic.get("vmnic0")
    $elxnet = $esxcli.software.vib.list() | Where-Object { $_.name -eq "smartpqi" }
    $lpfc = $esxcli.system.module.list() | Where-Object { $_.Name -eq '*' }

    if ($lpfc) {
        $lpfc = $esxcli.system.module.get("*")
    }

    $report += $ESXHost |
    Select-Object @{N = "Hostname"; E = { $_.Name } },
        @{N = "IPAddress"; E = { ($_ | Get-VMHostNetwork).VirtualNic | Where-Object { $_.ManagementTrafficEnabled } | Select-Object -ExpandProperty IP } },
        Manufacturer,
        ProcessorType,
        @{N = "BIOS version"; E = { $_.ExtensionData.Hardware.BiosInfo.BiosVersion } },
        @{N = "Hardware-Model"; E = { $HWModel.Model } },
        @{N = "Adapter-Firmware"; E = { $info.DriverInfo.FirmwareVersion } },
        @{N = "Network-Driver"; E = { $info.DriverInfo.Version } },
        @{N = "FC-Driver"; E = { $elxnet.version.substring(0, 14) } },
        @{N = "HBA Model"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Model) -join ", " } },
        @{N = "Driver"; E = { ($_ | get-vmhosthba | select-object -ExpandProperty Driver) -join ", " } },
        @{N = 'HBA-Module'; E = { $lpfc.Module } },
        @{N = 'HBA-Version'; E = { $lpfc.Version } }
}
$report | Export-Csv -Path $ResultFile -NoTypeInformation

ii $ResultFile

Open in new window

Avatar of JB Blanco

ASKER

Hi, thank you all for your help!  i was able to come up with one finally that gives me exactly what i am looking for.  Here is the script
$VsanCluster = Get-Cluster | Get-VsanClusterConfiguration | where VsanEnabled -eq 'True'
$esxhosts = Get-Cluster $VsanCluster | Get-VMHost

$cmdsub2 = 'hostname'
$cmdSub = '/opt/smartstorageadmin/ssacli/bin/ssacli ctrl all show detail | grep -E "Firmware Version:|Driver Version:|Driver Name: smartpqi"'
$cred = Get-Credential -Message "Credentials for ESXi node $($esxName)"
foreach ($esxname in $esxhosts) {
$esx = Get-VMHost -Name $esxName
 

$session = New-SSHSession -ComputerName $esx.Name -Credential $cred –AcceptKey
$result2 = Invoke-SSHCommand -SSHSession $session -Command $cmdSub2
$result = Invoke-SSHCommand -SSHSession $session -Command $cmdSub 
Remove-SSHSession -SSHSession $session | Out-Null 

 
$result2.Output
$result.Output
}

Open in new window


Just add > c:\temp\result.csv

in powershell to the command to run the script
ASKER CERTIFIED SOLUTION
Avatar of JB Blanco
JB Blanco
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Thank you