thiefqw
Contributor
Contributor

How to batch execute the following queries on ESXi hosts through Powercli

How to batch execute the following queries on ESXi hosts through Powercli: vsish - e get/vmkModules/vsanutil/stretchedClusterMode
Or other ways, thank you guys!

Reply
0 Kudos
LucD
Leadership
Leadership

Not directly an alternative for that vsish command, but you can check if the VSAM cluster has a preferred default domain.
With Get-EsxCli.

Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
   Write-Host "Cluster $($cluster.Name)  VMHost $($esx.Name)"
   $esx = Get-VMHost -Location $cluster | Get-Random -Count 1
   $esxcli = Get-EsxCli -VMHost $esx -V2
   $uuid = $esxcli.vsan.cluster.list.Invoke().LocalNodeUUID
   try{
      if($esxcli.vsan.cluster.preferredfaultdomain.get.Invoke(@{clusteruuid = $uuid }) 2> $null ){
         Write-Host "Stretched cluster"
      }

   }
   catch{
      Write-Host "Not a stretched cluster"
   }
}

Or via the Get-VsanView cmdlet

$sc = Get-VsanView -Id 'VimClusterVsanVcStretchedClusterSystem-vsan-stretched-cluster-system'

Get-Cluster -PipelineVariable cluster |
ForEach-Object -Process {
	Write-Host "Cluster $($cluster.Name)"
	$pd = $sc.VSANVcGetPreferredFaultDomain($cluster.Id)
	if($pd.preferredfaultdomain){
			Write-Host "Stretched cluster"
  }
	else {
		Write-Host "Not a stretched cluster"
	}
}

 


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

View solution in original post