VMware Cloud Community
AlbertWT
Virtuoso
Virtuoso
Jump to solution

Modifying script to list ESXi image edition and vSphere Edition ?

People,

Can anyone here please assist me in modifying the script below to include the vSphere Edition and ESXi image version ?

Get-VMHost | Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}}, 

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}}, 

        Manufacturer, 

        Model, 

        ProcessorType, 

        @{N="BIOS version";E={$_.ExtensionData.Hardware.BiosInfo.BiosVersion}}| Export-Csv C:\RESULT\ESXi-Reports.csv 

and

foreach($esxcli in Get-VMHost | Get-EsxCli -V2){

    $esxcli.hardware.platform.get.Invoke() |

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},VendorName,ProductName,SerialNumber

}

Thanks in advance.

/* Please feel free to provide any comments or input you may have. */
1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Is this returning the info you want?

Get-VMHost |

Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},

        @{N='ESX';E={$_.ExtensionData.Config.Product.Name}},

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

        @{N='ESX build';E={$_.Build}},

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}}, 

        Manufacturer, 

        Model, 

        ProcessorType, 

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

        @{N='Serial';E={(Get-EsxCli -V2 -VMHost $_).hardware.platform.get.Invoke().SerialNumber}},

        @{N='HostProfile';E={ ($_ | Get-VMHostProfile).Name}},

        @{N='ImageProfile';E={(Get-EsxCli -V2 -VMHost $_).software.profile.get.Invoke().Name}},

        @{N='License';E={$key = $_.LicenseKey; (Get-View (Get-View ServiceInstance).Content.LicenseManager).Licenses | where{$_.LicenseKey -eq $key} | select -ExpandProperty Name}},

        @{N='CPU Cores';E={"{0:N0} CPUs x {1:N3} GHz" -f $_.ExtensionData.Hardware.CpuInfo.NumCpuThreads,($_.ExtensionData.Hardware.CpuInfo.Hz/1E9)}}


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

View solution in original post

8 Replies
LucD
Leadership
Leadership
Jump to solution

You mean something like this?

Get-VMHost | Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},

        @{N='ESX';E={$_.ExtensionData.Config.Product.Name}},

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

        @{N='ESX build';E={$_.Build}},

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}},   

        Manufacturer,   

        Model,   

        ProcessorType,   

        @{N="BIOS version";E={$_.ExtensionData.Hardware.BiosInfo.BiosVersion}}| Export-Csv C:\ESXi-Reports.csv

and

foreach($esxcli in Get-VMHost | Get-EsxCli -V2){

    $esxVersion = $esxcli.system.version.get.Invoke()

    $esxcli.hardware.platform.get.Invoke() | 

    Select @{N='VMHost';E={$esxcli.VMHost.Name}},VendorName,ProductName,SerialNumber,

        @{N='Product';E={$esxVersion.Product}},

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

        @{N='Build';E={$esxVersion.Build}}


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

AlbertWT
Virtuoso
Virtuoso
Jump to solution

LucD , thanks for the quick reply.

What I'd like to get is the information like:

HostName      : PRODESX01

ESX           : VMware ESXi

ESX Version   : 5.5.0

ESX build     : 3620759

IPAddress     : 10.1.1.5

Manufacturer  : HP

Model         : ProLiant DL360 Gen9

ProcessorType : Intel(R) Xeon(R) CPU E5-2603 v3 @ 1.60GHz

BIOS version  : P89

SerialNumber  : SGH066PRDA

ESXi image profile: (Updated) ESXi-5.5.0-2014...

License: Vmware vSphere 5 Enterprise Plus....

Would that be possible to get / pull that information in bold ?

Because I need to know which ESXi servers are running with the standard generic ESXi .ISO file rather than running the proper HPE image and what the license type is.

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this

Get-VMHost |

Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},

        @{N='ESX';E={$_.ExtensionData.Config.Product.Name}},

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

        @{N='ESX build';E={$_.Build}},

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}},  

        Manufacturer,  

        Model,  

        ProcessorType,  

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

        @{N='Serial';E={(Get-EsxCli -V2 -VMHost $_).hardware.platform.get.Invoke().SerialNumber}},

        @{N='HostProfile';E={($_ | Get-VMHostProfile).Name}},

        LicenseKey


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

AlbertWT
Virtuoso
Virtuoso
Jump to solution

LucD

would it be possible to get the information like in the vSphere client below ?

ESXi.PNG

The script above returns empty for the host profile and showing me the license keys instead of the License type ?

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Try like this.

Hostprofile works for me. Can you check if Get-VMHost | Get-VMHostProfile returns the profiles?

Manufacturer and Model is already in the output.

Get-VMHost |

Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},

        @{N='ESX';E={$_.ExtensionData.Config.Product.Name}},

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

        @{N='ESX build';E={$_.Build}},

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}}, 

        Manufacturer, 

        Model, 

        ProcessorType, 

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

        @{N='Serial';E={(Get-EsxCli -V2 -VMHost $_).hardware.platform.get.Invoke().SerialNumber}},

        @{N='HostProfile';E={ ($_ | Get-VMHostProfile).Name}},

        @{N='License';E={$key = $_.LicenseKey; (Get-View (Get-View ServiceInstance).Content.LicenseManager).Licenses | where{$_.LicenseKey -eq $key} | select -ExpandProperty Name}},

        @{N='CPU Cores';E={"{0:N0} CPUs x {1:N3} GHz" -f $_.ExtensionData.Hardware.CpuInfo.NumCpuThreads,($_.ExtensionData.Hardware.CpuInfo.Hz/1E9)}}


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

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Hi Lucd,

Yes, the HostProfile is working and can be seen from the script above. Sadly it is not properly implemented in my VCenter.

However, I just wanted to know if it is possible to get the ESXi image that was used for the installation on the ESXi host ?

Because some of the ESXi host is installed using the generic ESXi .ISO file while the proper one is installed with HP or Dell custom ESXi image. Is there any way to pull that information ?

/* Please feel free to provide any comments or input you may have. */
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Is this returning the info you want?

Get-VMHost |

Select-object @{N="HostName";E={ $_ | Get-VMHostNetwork | select -ExpandProperty Hostname}},

        @{N='ESX';E={$_.ExtensionData.Config.Product.Name}},

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

        @{N='ESX build';E={$_.Build}},

        @{N="IPAddress"; E={($_ | Get-VMHostNetwork).VirtualNic | Where-Object {$_.ManagementTrafficEnabled} | Select-Object -ExpandProperty IP}}, 

        Manufacturer, 

        Model, 

        ProcessorType, 

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

        @{N='Serial';E={(Get-EsxCli -V2 -VMHost $_).hardware.platform.get.Invoke().SerialNumber}},

        @{N='HostProfile';E={ ($_ | Get-VMHostProfile).Name}},

        @{N='ImageProfile';E={(Get-EsxCli -V2 -VMHost $_).software.profile.get.Invoke().Name}},

        @{N='License';E={$key = $_.LicenseKey; (Get-View (Get-View ServiceInstance).Content.LicenseManager).Licenses | where{$_.LicenseKey -eq $key} | select -ExpandProperty Name}},

        @{N='CPU Cores';E={"{0:N0} CPUs x {1:N3} GHz" -f $_.ExtensionData.Hardware.CpuInfo.NumCpuThreads,($_.ExtensionData.Hardware.CpuInfo.Hz/1E9)}}


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

AlbertWT
Virtuoso
Virtuoso
Jump to solution

Yes, you are awesome LucD​ that works flawlessly.

Many thanks for the assistance.

/* Please feel free to provide any comments or input you may have. */
0 Kudos