VMware Cloud Community
SCharchouf
Hot Shot
Hot Shot

Get All information regarding ESXi Firmware Driver installed VIB

Hello

I'm looking for a script that can allow me to get all the below details from differentes hosts managed by differentes vCenter

Firmware

Drivers

ESXi version

installed VIB

Patches

Any idea? help?

54 Replies
SCharchouf
Hot Shot
Hot Shot

Ah Ok, so if I attache a BaseLine to esxi, I can identfy the missing patches in the report, right?

yes if possible, please Smiley Happy

Reply
0 Kudos
LucD
Leadership
Leadership

Try like this

#Requires Modules ImportExcel

$fileName = '.\report.xlsx'


$reportVIB = @()

$reportPatch = @()


$global:DefaultVIServers |

ForEach-Object -Process {

    Get-VMHost -Server $_ -PipelineVariable esx |

    ForEach-Object -Process {

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


        $reportVIB += $esxcli.software.vib.list.Invoke() |

        Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            Name,ID,CreationDate,InstallDate,Version,Vendor,AcceptanceLevel


        Get-Compliance -Entity $esx -Detailed -PipelineVariable baseline |

        where{$_ -is [VMware.VumAutomation.Types.PatchBaselineCompliance]} |

        ForEach-Object -Process {

            $reportPatch += $baseline.CompliantPatches |

            Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            @{N='Baseline';E={$baseline.Baseline.Name}},

            @{N='Compliant';E={$true}},

            Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}


            $reportPatch += $baseline.NotCompliantPatches |

            Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            @{N='Baseline';E={$baseline.Baseline.Name}},

            @{N='Compliant';E={$false}},

            Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}

        }

    }

}


$reportVIB | Export-Excel -Path $fileName -WorksheetName 'VIB'

$reportPatch | Export-Excel -Path $fileName -WorksheetName 'Patch'


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

SCharchouf
Hot Shot
Hot Shot

Perfect is working fine except that Firmware information is not there.

I will attach shortly an ESX image to hosts and run the script again in order to check if I will get Patches information

Reply
0 Kudos
LucD
Leadership
Leadership

What firmware information?


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

Reply
0 Kudos
SCharchouf
Hot Shot
Hot Shot

For Network Card

Reply
0 Kudos
LucD
Leadership
Leadership

Added the worksheet NIC

#Requires Modules ImportExcel

$fileName = '.\report.xlsx'


$reportVIB = @()

$reportPatch = @()

$reportNic = @()


$global:DefaultVIServers |

ForEach-Object -Process {

    Get-VMHost -Server $_ -PipelineVariable esx |

    ForEach-Object -Process {

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


        $reportVIB += $esxcli.software.vib.list.Invoke() |

        Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            Name,ID,CreationDate,InstallDate,Version,Vendor,AcceptanceLevel


        Get-Compliance -Entity $esx -Detailed -PipelineVariable baseline |

        where{$_ -is [VMware.VumAutomation.Types.PatchBaselineCompliance]} |

        ForEach-Object -Process {

            $reportPatch += $baseline.CompliantPatches |

            Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            @{N='Baseline';E={$baseline.Baseline.Name}},

            @{N='Compliant';E={$true}},

            Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}


            $reportPatch += $baseline.NotCompliantPatches |

            Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

            @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

            @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

            @{N='VMHost Version';E={$esx.Version}},

            @{N='VMHost Build';E={$esx.Build}},

            @{N='Baseline';E={$baseline.Baseline.Name}},

            @{N='Compliant';E={$false}},

            Name,Vendor,IdByVendor,ReleaseDate,LastUpdateTime,Severity,@{N='Product';E={$_.Product.Name}}

        }


        $reportNic += $esxcli.network.nic.list.Invoke() |

            ForEach-Object -Process {

                $pMAC = $_.MACAddress

                $esxcli.network.nic.get.Invoke(@{nicname=$_.Name}) |

                Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

                    @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

                    @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

                    @{N='VMHost Version';E={$esx.Version}},

                    @{N='VMHost Build';E={$esx.Build}},

                    @{N='NIC';E={$_.Name}},

                    @{N='pMAC';E={$pMAC}},         

                    @{N='vMAC';E={$_.VirtualAddress}},         

                    @{N='LinkStatus';E={$_.LinkStatus}},

                    @{N='Driver';E={$_.DriverInfo.Driver}},         

                    @{N='Version';E={$_.DriverInfo.Version}},

                    @{N='FirmwareVersion';E={$_.DriverInfo.FirmwareVersion}}

        }

    }

}


$reportVIB | Export-Excel -Path $fileName -WorksheetName 'VIB'

$reportPatch | Export-Excel -Path $fileName -WorksheetName 'Patch'

$reportNic | Export-Excel -Path $fileName -WorksheetName 'NIC'


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

SCharchouf
Hot Shot
Hot Shot

Tested and I got the below error message

Select : The property cannot be processed because the property "Driver" already exists.

At C:.\\VIB_Firmware_Drivers_Details.ps1:107 char:17

+ ...             Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.S ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (VMware.VimAutom...sxCliObjectImpl:PSObject) [Select-Object], PSArgumentException

    + FullyQualifiedErrorId : AlreadyExistingUserSpecifiedPropertyNoExpand,Microsoft.PowerShell.Commands.SelectObjectCommand

Select : The property cannot be processed because the property "pMAC" already exists.

At C:.\\VIB_Firmware_Drivers_Details.ps1:107 char:17

+ ...             Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.S ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (VMware.VimAutom...sxCliObjectImpl:PSObject) [Select-Object], PSArgumentException

    + FullyQualifiedErrorId : AlreadyExistingUserSpecifiedPropertyNoExpand,Microsoft.PowerShell.Commands.SelectObjectCommand

Select : The property cannot be processed because the property "Driver" already exists.

At C:.\\VIB_Firmware_Drivers_Details.ps1:107 char:17

+ ...             Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.S ...

+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

    + CategoryInfo          : InvalidOperation: (VMware.VimAutom...sxCliObjectImpl:PSObject) [Select-Object], PSArgumentException

    + FullyQualifiedErrorId : AlreadyExistingUserSpecifiedPropertyNoExpand,Microsoft.PowerShell.Commands.SelectObjectCommand

Reply
0 Kudos
LucD
Leadership
Leadership

My bad, copy/paste error.

I corrected the code above.


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

Reply
0 Kudos
SCharchouf
Hot Shot
Hot Shot

No issue Smiley Happy

New error Smiley Happy

Get-EsxCli : 24/04/2020 09:25:49    Get-EsxCli          Thread failed to start.

At C:PATH\VIB_Firmware_Drivers_Details.ps1:33 char:19

+     $esxcli = Get-EsxCli -VMHost $esx -V2
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : NotSpecified: (:) [Get-EsxCli], VimException
+ FullyQualifiedErrorId : Core_BaseCmdlet_UnknownError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli
LucD
Leadership
Leadership

That is most probably not an error in the script.

Can you stop/start your PowerShell session and try again?


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

Reply
0 Kudos
SCharchouf
Hot Shot
Hot Shot

a new PowerCLI session I run the script against one vCenter and I got the below

Get-EsxCli : 24/04/2020 13:04:35    Get-EsxCli          Message: vim.fault.NoHost;

InnerText: Invalid fault

At .\\VIB_Firmware_Drivers_Details.ps1:36 char:19

+     $esxcli = Get-EsxCli -VMHost $esx -V2
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : NotSpecified: (:) [Get-EsxCli], ViError
+ FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:38 char:9

+     $reportVIB += $esxcli.software.vib.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:102 char:9

+     $reportNic += $esxcli.network.nic.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Get-EsxCli : 24/04/2020 13:05:18    Get-EsxCli          Message: vim.fault.NoHost;

InnerText: Invalid fault

At .\\VIB_Firmware_Drivers_Details.ps1:36 char:19

+     $esxcli = Get-EsxCli -VMHost $esx -V2
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : NotSpecified: (:) [Get-EsxCli], ViError
+ FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:38 char:9

+     $reportVIB += $esxcli.software.vib.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:102 char:9

+     $reportNic += $esxcli.network.nic.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

Get-EsxCli : 24/04/2020 13:06:01    Get-EsxCli          Message: vim.fault.NoHost;

InnerText: Invalid fault

At .\\VIB_Firmware_Drivers_Details.ps1:36 char:19

+     $esxcli = Get-EsxCli -VMHost $esx -V2
+               ~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : NotSpecified: (:) [Get-EsxCli], ViError
+ FullyQualifiedErrorId : Client20_DynamicTypeManagerServiceImpl_GetMoInstances_ViError,VMware.VimAutomation.ViCore.Cmdlets.Commands.EsxCli.GetEsxCli

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:38 char:9

+     $reportVIB += $esxcli.software.vib.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull

You cannot call a method on a null-valued expression.

At .\\VIB_Firmware_Drivers_Details.ps1:102 char:9

+     $reportNic += $esxcli.network.nic.list.Invoke() |
+     ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo      : InvalidOperation: (:) [], RuntimeException
+ FullyQualifiedErrorId : InvokeMethodOnNull
Reply
0 Kudos
LucD
Leadership
Leadership

That is not an error in the script, but in your environment.

The Get-EsxCli cmdlet doesn't seem to work against one or more of the ESXi nodes in your environment.

Run a check which ESXi node are having this issue

Get-VMHost |

Select Name,

    @{N='EsxCli';E={

            $esxcli = Get-EsxCli -VMHost $_ -V2 -ErrorAction SilentlyContinue

            if($esxcli){'OK'}else{'Fail'}}}


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

Reply
0 Kudos
SCharchouf
Hot Shot
Hot Shot

I checked all ESXi nodes, and all reported the Cmdlet OK

Reply
0 Kudos
LucD
Leadership
Leadership

Can you add a line to find out for which ESXi node the issue occurs?

$global:DefaultVIServers |

ForEach-Object -Process {

    Get-VMHost -Server $_ -PipelineVariable esx |

    ForEach-Object -Process {

        Write-Host "Looking at $($esx.Name)"

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


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

SCharchouf
Hot Shot
Hot Shot

Not sure what happend, the script is working fine now and I got the report
really the script is very nice and for sure will help me a lot Smiley Happy Smiley Happy

it's possible that the script can retreive the server hardware information for exemple HP blade 460c Gen8

As I would like the below to your script in order to get more details

@{N=Type;E={$_.Hardware.SystemInfo.Vendor+ + $_.Hardware.SystemInfo.Model}},

@{N="BIOS version";E={$_.Hardware.BiosInfo.BiosVersion}},

   @{N="BIOS date";E={$_.Hardware.BiosInfo.releaseDate}}

Reply
0 Kudos
LucD
Leadership
Leadership

You should be able to add those properties to any of the 3 worksheets.

Just make sure to use the $esx variable

@{N=“Type“;E={$esx.ExtensionData.Hardware.SystemInfo.Vendor+ “ “ + $esx.ExtensionData.Hardware.SystemInfo.Model}},

@{N="BIOS version";E={$esx.ExtensionData.Hardware.BiosInfo.BiosVersion}}, 

@{N="BIOS date";E={$esx.ExtensionData.Hardware.BiosInfo.releaseDate}}


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

SCharchouf
Hot Shot
Hot Shot

I added the properties to the script

    $reportNic += $esxcli.network.nic.list.Invoke() |

        ForEach-Object -Process {

            $pMAC = $_.MACAddress

            $esxcli.network.nic.get.Invoke(@{nicname=$_.Name}) |

            Select @{N='vCenter';E={([uri]$esx.ExtensionData.Client.ServiceUrl).Host}},

                @{N='vCenter Version';E={$esx.ExtensionData.Client.ServiceContent.About.Version}},

                @{N='vCenter Build';E={$esx.ExtensionData.Client.ServiceContent.About.Build}},

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

                @{N='VMHost Version';E={$esx.Version}},

                @{N='VMHost Build';E={$esx.Build}},

                @{N='NIC';E={$_.Name}},

                @{N='pMAC';E={$pMAC}},   

                @{N='vMAC';E={$_.VirtualAddress}},   

                @{N='LinkStatus';E={$_.LinkStatus}},

                @{N='Driver';E={$_.DriverInfo.Driver}},   

                @{N='Version';E={$_.DriverInfo.Version}},

                @{N='FirmwareVersion';E={$_.DriverInfo.FirmwareVersion}},
  
   @{N=“Type“;E={$esx.ExtensionData.Hardware.SystemInfo.Vendor+““+$esx.ExtensionData.Hardware.SystemInfo.Model}},
  
   @{N="BIOS version";E={$esx.ExtensionData.Hardware.BiosInfo.BiosVersion}},
  
  

@{N="BIOS date";E={$esx.ExtensionData.Hardware.BiosInfo.releaseDate}}

I got this message

PowerCLI C: .\VIB_Firmware_Drivers_Details.ps1

At C:.PATH\VIB_Firmware_Drivers_Details\VIB_Firmware_Drivers_Details.ps1:136 char:70

+ ... =â?oTypeâ?o;E={$esx.ExtensionData.Hardware.SystemInfo.Vendor+â?oâ?o+$ ...

+                                                                  ~

You must provide a value expression following the '+' operator.

At C:.PATH\VIB_Firmware_Drivers_Details\VIB_Firmware_Drivers_Details.ps1:136 char:70

+ ... temInfo.Vendor+â?oâ?o+$esx.ExtensionData.Hardware.SystemInfo.Model}},

+                    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Unexpected token 'â?oâ?o+$esx.ExtensionData.Hardware.SystemInfo.Model' in expression or statement.

    + CategoryInfo          : ParserError: (:) [], ParseException

    + FullyQualifiedErrorId : ExpectedValueExpression

Reply
0 Kudos
LucD
Leadership
Leadership

There are again some funny characters in the text show in the error message.

Looks like the double quotes are not ok.

Replace the quotes in the copied text with real double quotes


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

SCharchouf
Hot Shot
Hot Shot

I added the below unfortunately not able to get details

@{N="CPU";E={$_.Hardware.CpuPkg[0].Description}}

Reply
0 Kudos
LucD
Leadership
Leadership

That should be

@{N = "CPU"; E = { $esx.ExtensionData.Hardware.CpuPkg[0].Description } },


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