VMware Cloud Community
MartyG
Contributor
Contributor

Identify host configured with vsan

Trying to query a virtual center for ESXi hosts using vsan then getting a health report. Is there an easy way to identify hosts using vsan with powercli. As I look at some of the vsan powercli commands they will just return errors if vsan is not enabled. I could just use error handling in powershell but I would think easy way to query a host, skip if not using vsan and continue.

 

thanks

Reply
0 Kudos
2 Replies
LucD
Leadership
Leadership

You could do something like this.

You can retrieve more info from the object returned by the VsanQueryVcClusterHealthSummary method.
You could even run a VsanQueryVcClusterHealthSummaryTask before to make sure you have (very) recent info. 

$hCheck = Get-VsanView -Id 'VsanVcClusterHealthSystem-vsan-cluster-health-system'
Get-VMHost -PipelineVariable esx | ForEach-Object -Process {
  $cluster = Get-Cluster -VMHost $esx
  $obj = [ordered]@{
    VMHost = $esx.Name
    Cluster = $cluster.Name
    VSANEnabled = $false
    VSANHealth = 'na'
  }
  if ($esx.ExtensionData.Config.vsanHostConfig.Enabled){
    $result = $hCheck.VsanQueryVcClusterHealthSummary($cluster.EXtensionData.MoRef, $null, $null, $null, $null, $true, $null, $esx.ExtensionData.MoRef)
    $obj.VSANEnabled = $true
    $obj.VSANHealth = $result.OverallHealth
  }
  New-Object -TypeName PSObject -Property $obj
}


 


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

Reply
0 Kudos
MartyG
Contributor
Contributor

thanks  I will give in a try  

Reply
0 Kudos