VMware Cloud Community
faherne_CTI
Enthusiast
Enthusiast
Jump to solution

List the CPU model for the first Cluster host of multiple ESXi Clusters on Multiple vCenters (Identify Intel bug Affected Clusters)

Hi,

With the recent Intel CPU exploits announcement, we are looking to identify the affected clusters. I want to generate a CSV file with the following columns:

vCenterName, DataCenterName, ClusterName, No. of ESXi Cluster Hosts, ESXi Host Hardware Model, ESXi version, ESXi Build No., CPU model

e.g.:

vCenter1, EMEA, Cluster1, 10, HP DL380 Gen8, ESXi 5.0.0, Build 1234567, Intel Xeon intel X5650 v3

vCenter1, EMEA, Cluster2, 12, HP DL380 Gen9, ESXi 5.5.0, Build 2345678, Intel Xeon intel X5650 v3

vCenter2, EMEA, Cluster3, 10, HP DL380 Gen8, ESXi 5.0.0, Build 1234567, Intel Xeon intel X5650 v3

vCenter2, EMEA, Cluster4, 12, HP DL380 Gen9, ESXi 5.5.0, Build 2345678, Intel Xeon intel X5650 v3

Assumptions:

- We have multiple vCenters each with multiple ESXi clusters

- Most Clusters have multiple hosts, but some clusters have no hosts (Being built or decommissioned)

- Each cluster has identical servers with identical CPU models (so I don't need to list all cluster hosts ESXi Host Hardware Model, ESXi version, ESXi Build No., just the first server node)

- I don't know how to grab the first host of each cluster to pull the ESXi Host Hardware Model, ESXi version, ESXi Build No., CPU Model

- I don't know how to ignore clusters with no hosts

The script I have so far is:

Connect-viserver -Server (Get-Content C:\Scripts\vCenterList.txt) > $null

$report = Foreach($vc in $global:DefaultVIServers){

    foreach($dc in Get-Datacenter -Server $vc){

        Get-Cluster -Location $dc -Server $vc |

        Select @{N='VC';E={$vc.Name}},

            @{N='Datacenter';E={$dc.Name}},

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

            @{N='#ESXi';E={$_.ExtensionData.Host.Count}},

    }

}

$report | Export-Csv C:\Scripts\vCenterClusterInfo.csv

1 Solution

Accepted Solutions
LucD
Leadership
Leadership
Jump to solution

Try like this

Connect-VIServer -Server (Get-Content C:\Scripts\vCenterList.txt) > $null

$report = Foreach($vc in $global:DefaultVIServers){

    foreach($dc in Get-Datacenter -Server $vc){

        Get-Cluster -Location $dc -Server $vc -PipelineVariable cluster |

        Get-VMHost |

        Select @{N='VC';E={$vc.Name}},

            @{N='Datacenter';E={$dc.Name}},

            @{N='Cluster';E={$cluster.Name}},

            @{N='#ESXi';E={$cluster.ExtensionData.Host.Count}},

            Name,

            @{N='ESXi version';E={"$($_.Version) $($_.Build)"}},

            @{N='ESXi HW';E={"$($_.ExtensionData.Hardware.SystemInfo.Vendor) $($_.ExtensionData.Hardware.SystemInfo.Model)"}},

            @{N='ESXi CPU';E={$_.ProcessorType}}

    }

}

$report | Export-Csv C:\Scripts\vCenterClusterInfo.csv


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

View solution in original post

9 Replies
LucD
Leadership
Leadership
Jump to solution

Try like this

Connect-VIServer -Server (Get-Content C:\Scripts\vCenterList.txt) > $null

$report = Foreach($vc in $global:DefaultVIServers){

    foreach($dc in Get-Datacenter -Server $vc){

        Get-Cluster -Location $dc -Server $vc -PipelineVariable cluster |

        Get-VMHost |

        Select @{N='VC';E={$vc.Name}},

            @{N='Datacenter';E={$dc.Name}},

            @{N='Cluster';E={$cluster.Name}},

            @{N='#ESXi';E={$cluster.ExtensionData.Host.Count}},

            Name,

            @{N='ESXi version';E={"$($_.Version) $($_.Build)"}},

            @{N='ESXi HW';E={"$($_.ExtensionData.Hardware.SystemInfo.Vendor) $($_.ExtensionData.Hardware.SystemInfo.Model)"}},

            @{N='ESXi CPU';E={$_.ProcessorType}}

    }

}

$report | Export-Csv C:\Scripts\vCenterClusterInfo.csv


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

faherne_CTI
Enthusiast
Enthusiast
Jump to solution

Thanks for that Luc - it worked a treat!

I hope other community members find that script useful too!

Reply
0 Kudos
chaos007m
Contributor
Contributor
Jump to solution

I like this script, but I have multiple clusters in my vCenter\data center. How can I change this script to add scanning all hosts within each cluster?
Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

The script is producing a report with each vCenter you're connected to, each datacenter, each cluster and each ESXi node.

Or do you mean something else?

Could you show me the layout of the report you would want to see?


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

Reply
0 Kudos
chaos007m
Contributor
Contributor
Jump to solution

I'm simply looking for a script to expand the CPU information, to include CPU procession model. I'm not well versed in Power CLi and when I tried to run the above example it get nothing be errors.

Here is what I have been able to extract but need to gether "Intel Xeon E3-*****" information.

hostname  Dell Inc. PowerEdge M630      PROC:2 CORES:24 MHZ: 2494     256 GB
hostname  Dell Inc. PowerEdge M630      PROC:2 CORES:24 MHZ: 2494     256 GB

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Did you use the script above?

Because that should give you the CPU type in the "ESXi CPU" property.

If not, can you show us the script you are using?


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

Reply
0 Kudos
chaos007m
Contributor
Contributor
Jump to solution

I have actually been using this: Because I couldn't get the other to work. Again, I'm no powercli person. Yes, I did change the vCenter name on the report script and still didn't work for me.

Sort Name |Get-View | Select Name, @{N=“Type“;E={$_.Hardware.SystemInfo.Vendor+ “ “ + $_.Hardware.SystemInfo.Model}}, @{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}}, @{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}}

When I run the report script. It appears to execute and create the "vCenterClusterInfo.csv" file with no data. I do not receive any error messages as well.

Reply
0 Kudos
LucD
Leadership
Leadership
Jump to solution

Perhaps something went wrong during the copy/paste, but that code fragment is not writing anything to a CSV.

Try this, and check if it returns the information you want to see.

Get-View -ViewType HostSystem | sort -Property Name |

Select Name,

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

    @{N=“CPU“;E={“PROC:“ + $_.Hardware.CpuInfo.NumCpuPackages + “ CORES:“ + $_.Hardware.CpuInfo.NumCpuCores + “ MHZ: “ + [math]::round($_.Hardware.CpuInfo.Hz / 1000000, 0)}},

    @{N=“MEM“;E={“” + [math]::round($_.Hardware.MemorySize / 1GB, 0) + “ GB“}},

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


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

Reply
0 Kudos
chaos007m
Contributor
Contributor
Jump to solution

Yes, this worked just perfect... Thank you so much.

Output below:

Name     : hostname
Type     : Dell Inc. PowerEdge M630
CPU      : PROC:2 CORES:24 MHZ: 2195
MEM      : 512 GB
ESXi CPU : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz

Name     : hostname
Type     : Dell Inc. PowerEdge M630
CPU      : PROC:2 CORES:24 MHZ: 2195
MEM      : 512 GB
ESXi CPU : Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz

Reply
0 Kudos