Johan77
Enthusiast
Enthusiast

PowerCLI Script to get ESXi Network/Storage Firmware and Driver Version

Jump to solution

Hi Admin,

Found this script which gets me firmware and driver info.

-------

$vmhosts = Get-Cluster "clust01" | get-vmHost

$report = @()

foreach( $ESXHost in $vmhosts) {

$HWModel = get-vmHost $ESXHost | Select Name, Model

$esxcli = Get-ESXcli -vmhost $ESXHost

if($HWModel.Model -eq "ProLiant BL460c Gen9")

{

$info = $esxcli.network.nic.get("vmnic0").DriverInfo | select Driver, FirmwareVersion, Version

$ModuleName = "$($info.Driver)"

$Firmware = "$($info.FirmwareVersion)"

$Driver = "$($info.Version)"

$elxnet = $esxcli.software.vib.list() | where { $_.name -eq "elxnet"}

$report += $info | select @{N="Hostname"; E={$ESXHost}},@{N="Hardware-Model"; E={$HWModel.Model}},@{N="Adapter-Firmware"; E={$Firmware}}, @{N="Network-Driver"; E={$Driver}}, @{N="FC-Driver"; E={$elxnet.version.substring(0,14)}}

}

}

$report | out-gridview

-------

Above works fine for my blade servers with CNAs.

But on some om my VMhost I have separate FC HBAs , and to get the driver info I use something like this :
$esxcli.system.module.get("lpfc") | Select-object @{N="VMHostName";E={$VMHostName}}, Module, Version

Possible to combine this line with my script someway?  

Thanks

Johan

31 Replies
vmk2014
Expert
Expert

LucD,

Does the script works for CISCO UCS blade model also ? We have mixed environment of HP and UCS blade.

Thanks

vmk

0 Kudos
LucD
Leadership
Leadership

I wouldn't know, I don't have such HW available to verify that.
Did you try to run it against that HW?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
vmk2014
Expert
Expert

No LucD, i didn't try to run. I will try to run and revert back

0 Kudos
SergOO
Enthusiast
Enthusiast

#$vmhosts = Get-Cluster " clust01 " | Get-VMHost

$vmhosts = get-vmhost "myhost"

$report = @() 

foreach ( $ESXHost in $vmhosts) {

    $esxcli = Get-EsxCli -vmhost $ESXHost

    $nicfirmware = $esxcli.network.nic.list()

    $fcfirmware = $esxcli.storage.san.fc.list()

    $driversoft = $esxcli.software.vib.list()

        foreach($nicfirmwareselect in $nicfirmware)

            {

                $NetworDescription = $nicfirmwareselect.Description

                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }

                $NetworkName = $nicfirmwareselect.Name

                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion

 

                $report += "" |

                select @{N = "Hostname"; E = { $ESXHost.Name } },

                @{N = "Hardware-Model"; E = { $ESXHost.Model } },

                @{N = "device"; E = { $NetworkName } },

                @{N = "driver"; E = { $NetworDriver.Version } },

                @{N = "firmware"; E = { $NetworkFirmware } },

                @{N = "description"; E = { $NetworDescription } }

            }

        foreach($fcfirmwareselect in $fcfirmware)

            {

                $fcDescription = $fcfirmwareselect.ModelDescription

                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }

                $fcName = $fcfirmwareselect.Adapter

                $fcFirmware = $fcfirmwareselect.FirmwareVersion

 

                $report += "" |

                select @{N = "Hostname"; E = { $ESXHost.Name } },

                @{N = "Hardware-Model"; E = { $ESXHost.Model } },

                @{N = "device"; E = { $fcName } },

                @{N = "driver"; E = { $fcDriver.Version } },

                @{N = "firmware"; E = { $fcFirmware } },

                @{N = "description"; E = { $fcDescription } }

            }

}

 

$report | ft -AutoSize -Wrap

#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap#$vmhosts = Get-Cluster " clust01 " | Get-VMHost
$vmhosts = get-vmhost "desxisvmp87.alfa.bank.int"
$report = @()
 
 
foreach ( $ESXHost in $vmhosts) {
    $esxcli = Get-EsxCli -vmhost $ESXHost
 
    $nicfirmware = $esxcli.network.nic.list()
    $fcfirmware = $esxcli.storage.san.fc.list()
    $driversoft = $esxcli.software.vib.list()
        foreach($nicfirmwareselect in $nicfirmware)
            {
                $NetworDescription = $nicfirmwareselect.Description
                $NetworDriver = $driversoft | where { $_.name -eq ($nicfirmwareselect.Driver) }
                $NetworkName = $nicfirmwareselect.Name
                $NetworkFirmware = ($esxcli.network.nic.get($nicfirmwareselect.Name)).DriverInfo.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $NetworkName } },
                @{N = "driver"; E = { $NetworDriver.Version } },
                @{N = "firmware"; E = { $NetworkFirmware } },
                @{N = "description"; E = { $NetworDescription } }
            }
        foreach($fcfirmwareselect in $fcfirmware)
            {
                $fcDescription = $fcfirmwareselect.ModelDescription
                $fcDriver = $driversoft | where { $_.name -eq ($fcfirmwareselect.DriverName) }
                $fcName = $fcfirmwareselect.Adapter
                $fcFirmware = $fcfirmwareselect.FirmwareVersion
 
                $report += "" |
                select @{N = "Hostname"; E = { $ESXHost.Name } },
                @{N = "Hardware-Model"; E = { $ESXHost.Model } },
                @{N = "device"; E = { $fcName } },
                @{N = "driver"; E = { $fcDriver.Version } },
                @{N = "firmware"; E = { $fcFirmware } },
                @{N = "description"; E = { $fcDescription } }
            }
 
}
 
$report | ft -AutoSize -Wrap
Raghukalloor
Contributor
Contributor

Hi Lucd,
Good day !!

For getting ISCSI HBA firmware & driver version and NIC firmware and driver version how can we modify with existing script or anything new which simplify it.. Normally whatever scripts i saw all extract information for FC HBAs .. I need ISCSi HBA details

0 Kudos
LucD
Leadership
Leadership

You could start with something like this

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

     $esxcli = Get-EsxCli -VMHost $esx -V2

     $esxcli.iscsi.adapter.list.Invoke() |

     ForEach-Object -Process {

          $esxcli.iscsi.adapter.get.Invoke(@{adapter="$($_.Adapter)"})

     }

}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Raghukalloor
Contributor
Contributor

Hi Lucd,
It gives a bunch of information. Can we limit those information as below
VMhost, description, Drivername, Driverversion, Firmwareversion, ID, name,vendor

2. Can we club even NIC driver and firmware information aswell.

0 Kudos
LucD
Leadership
Leadership

You can use a Select-Object to only show the properties you want.

The NIC info is obtained in the same way as in the other snippets in this thread.


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos
Raghukalloor
Contributor
Contributor

Thanks Lucd,

Will give a try.

0 Kudos
Raghukalloor
Contributor
Contributor

I couldn't get the desired output when i place select-object for the below script. Could you help me in placing those.

Get-VMHost -PipelineVariable esx |

ForEach-Object -Process {

     $esxcli = Get-EsxCli -VMHost $esx -V2

     $esxcli.iscsi.adapter.list.Invoke() |

     ForEach-Object -Process {

          $esxcli.iscsi.adapter.get.Invoke(@{adapter="$($_.Adapter)"})

     }

}

0 Kudos
Raghukalloor
Contributor
Contributor

Hi Lucd,


I made it .pls see the below output. How can i get the hostname to get published in the report?

Get-VMHost  -PipelineVariable esx |

ForEach-Object -Process {

     $esxcli = Get-EsxCli -VMHost $esx -V2

     $esxcli.iscsi.adapter.list.Invoke() |

     ForEach-Object -Process {

          $esxcli.iscsi.adapter.get.Invoke(@{adapter="$($_.Adapter)"}) | Select-Object description, Drivername, Driverversion, Firmwareversion, ID, name,vendor

     }

}

0 Kudos
LucD
Leadership
Leadership

You could use a calculated property.

Get-VMHost  -PipelineVariable esx |

ForEach-Object -Process {

     $esxcli = Get-EsxCli -VMHost $esx -V2

     $esxcli.iscsi.adapter.list.Invoke() |

     ForEach-Object -Process {

          $esxcli.iscsi.adapter.get.Invoke(@{adapter="$($_.Adapter)"}) |

          Select-Object @{N='VMHost';E={$esx.Name}},

            description, Drivername, Driverversion, Firmwareversion, ID, name,vendor

     }


}


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference