JB Blanco
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!
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!
Try this Blanco:
or this one if it is does not working:
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
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
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
Just add > c:\temp\result.csv
in powershell to the command to run 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
}
Just add > c:\temp\result.csv
in powershell to the command to run the script
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thank you
https://www.virten.net/2017/03/powercli-script-to-get-networkstorage-firmware-and-driver-version/
https://code.vmware.com/forums/2530/vsphere-powercli#572418