powershellwmishutdowndestroyfailovercluster

shutdown cluster vs destroy cluster


We can get the info of the cluster that a machine is joined to, using Powershell (calling "Get-Cluster" command)

or WMI (calling ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\MSCluster", "SELECT * FROM MSCluster_Cluster"))

However, if we Shutdown the cluster these methods don't return any result. Same happens if we destroy the cluster.

If we query for cluster by calling Get-Cluster and don't get any result, how do we know if the cluster is Shutdown or Destroyed?


Solution

  • Using WMI, if we query for MSCluster_Service:

    ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\MSCluster", "SELECT * FROM MSCluster_Service");

    When the cluster is destroyed, it returns no element. When the cluster is shutdown, it returns an object, with State property equal to "Stopped" when the cluster is up and running, it returns an object, with State property equal to "Running"