Documentation – vSphere Clusters

I have put this function together for the purpose of documenting cluster settings.  Used it a fair bit to gather information on environments that I have come accross that have not been well documented.  In can be used as is but I’m fiddling around with it to produce some further information so likely to be updated in the near future.

Hopefully of some use – connect to vCenter from POWERCLI and run the function.



function Get-ClusterDetails {
    [string]$Clustername = '*'

The Get-ClusterDetails retrieves Information regarding Configuration of ESXi Clusters dor Documentation
Get-ClusterDetails -Clustername "Production_Cluster" | out-gridview
$clusters = Get-ClusterDetails -Clustername "Cluster1","Cluster2"
Chris Tucker 

$myCluster = Get-Cluster $Clustername
$GridObjects = 

$ClusterAudit = @()

foreach ($cluster in $mycluster) {

$GetCluster = get-cluster $

$ClusterDetails = New-Object PSObject
$ClusterDetails | Add-Member -name "DataCenter" -Value (Get-DataCenter -Cluster $ -MemberType NoteProperty
$ClusterDetails | Add-Member -name "ClusterName" -Value $ -MemberType NoteProperty
$ClusterDetails | Add-Member -name "ESXi Hosts" -Value $cluster.ExtensionData.summary.numhosts -MemberType NoteProperty
$ClusterDetails | Add-Member -name "HA Enabled" -Value $cluster.HAEnabled -MemberType Noteproperty
##CPU info
$CpuInfo = Get-View -ViewType HostSystem -Property Hardware.CpuInfo -SearchRoot $cluster.Id | Select @{n="NumCpuSockets"; e={$_.Hardware.CpuInfo.NumCpuPackages}}, @{n="NumCpuCores"; e={$_.Hardware.CpuInfo.NumCpuCores}}, @{n="NumCpuThreads"; e={$_.Hardware.CpuInfo.NumCpuThreads}} | Measure-Object -Sum NumCpuSockets,NumCpuCores,NumCpuThreads
$ClusterDetails | Add-Member -name "NumCPUs" -Value ($CpuInfo | ?{$_.Property -eq "NumCpuSockets"}).Sum -MemberType NoteProperty
$ClusterDetails | Add-Member -name "NumCPUCores" -Value ($CpuInfo | ?{$_.Property -eq "NumCpuCores"}).Sum -MemberType NoteProperty
##RAM info
$RAMinfo = ($GetCluster | Get-VMHost) | Select @{n="MemoryTotalGB"; e={$_.MemoryTotalGB}} | Measure-Object -Sum MemoryTotalGB
$RoundNumber = [math]::Round(($RAMInfo | ?{$_.Property -eq "MemoryTotalGB"}).Sum)
$ClusterDetails | Add-Member -name "TotalRAM GB" -Value $RoundNumber -MemberType NoteProperty
$EVCmode = $cluster.EVCMode
if (!$EVCmode) {
$ClusterDetails | Add-Member -name "EVC Mode" -Value "Disabled" -MemberType Noteproperty }
else {
$ClusterDetails | Add-Member -name "EVC Mode" -Value $cluster.EVCMode -MemberType Noteproperty }
If ($cluster.HAFailoverLevel -eq 1) {$HAenabled = "Enabled"} else {$HAenabled = $null}
$ClusterDetails | Add-Member -name "HA" -Value $HAenabled -MemberType Noteproperty
$ClusterDetails | Add-Member -name "Host Failures Tolerated" -Value $cluster.ExtensionData.Configuration.DasConfig.AdmissionControlPolicy.FailOverLevel -MemberType Noteproperty
$ClusterDetails | Add-Member -name "Default Restart Priority" -Value $cluster.HArestartpriority -MemberType Noteproperty
$ClusterDetails | Add-Member -name "VM Monitoring" -Value $cluster.ExtensionData.Configuration.DasConfig.VmMonitoring -MemberType Noteproperty
##Heartbeat Sensitivity
$HMSensitivity = @(
    Name = 'Low'
    MinUptime = 480
    FailureInterval = 120
    MaxFailureWindow = 604800

    Name = 'Medium'
    MinUptime = 240
    FailureInterval = 60
    MaxFailureWindow = 86400

    Name = 'High'
    MinUptime = 120
    FailureInterval = 30
    MaxFailureWindow = 3600
$Sensitive = $Getcluster | Select Name,
    @{N='Heartbeat Monitoring Sensitivity';E={
        $sensitivity = $HMSensitivity | where{$_.MinUptime -eq $GetCluster.ExtensionData.ConfigurationEx.DasConfig.DefaultVmSettings.VmToolsMonitoringSettings.MinUpTime}

$ClusterDetails | Add-Member -name "Heartbeat Sensitivity" -Value $sensitive.'Heartbeat Monitoring Sensitivity' -MemberType Noteproperty

##Datastore Heartbeats
$HeartBeatDS = $GetCluster | Select -Property @{Name='HeartbeatDatastore';Expression={(Get-View -Id $_.ExtensionData.Configuration.DasConfig.HeartbeatDatastore).Name}}

$ClusterDetails | Add-Member -name "Heartbeat Datastores" -Value $HeartBeatDS.HeartbeatDatastore -MemberType NoteProperty
$ClusterDetails | Add-Member -name "DRS Status" -Value $cluster.DrsEnabled -MemberType Noteproperty
$ClusterDetails | Add-Member -name "DRS Automation" -Value $cluster.DrsAutomationLevel -MemberType Noteproperty
$ClusterDetails | Add-Member -name "Migration Threshold" -Value $cluster.ExtensionData.ConfigurationEx.DrsConfig.VmotionRate -MemberType Noteproperty
$ClusterDetails | Add-Member -name "DPM Enabled" -Value $cluster.ExtensionData.ConfigurationEx.DpmConfigInfo.Enabled -MemberType Noteproperty
##VM restart policy
$ClusterDetails | Add-Member -name "VM restart policy" -Value $null -MemberType Noteproperty
$VMs = $Cluster | get-VM | ? {$_.HARestartPriority -ne "ClusterRestartPriority"} | Select name, harestartpriority
foreach ($VM in $VMs) {
$ClusterDetails | Add-Member -name $ -Value $VM.HArestartpriority -MemberType NoteProperty 
##DRS Rules
$ClusterDetails | Add-Member -name "DRS Rules" -Value $null -MemberType Noteproperty
$DRSRules = Get-DRSVMhostRule -Cluster $Cluster.Name
$DRSRulesVMs = $DRSRules | Select Name, Enabled, Type, @{Name="VM"; Expression={ $iTemp = @(); $_.VMIds | % { $iTemp += (Get-VM -Id $_).Name }; [string]::Join(";", $iTemp) }}
$i = 1
foreach ($Rule in $DRSRules) {
$n = 0
$ClusterDetails | Add-Member -name "Rule $i" -Value $DRSRulesVMs[$n].name -MemberType NoteProperty
$ClusterDetails | Add-Member -name "Rule $i Type" -Value $DRSRulesVMs[$n].type -MemberType NoteProperty
$ClusterDetails | Add-Member -name "Rule $i Enabled?"  -Value $DRSRulesVMs[$n].Enabled -MemberType NoteProperty
## $ClusterDetails | Add-Member -name "Rule $i VMs"  -Value $DRSRulesVMs[$n].VM -MemberType NoteProperty

$ClusterAudit += $ClusterDetails


Write-Output $ClusterAudit

In action run against my homelab

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *