public void FailOverClusterNode(string host) { ManagementScope scope = GetWmiManagementScope(host); string fqdnHostName = $"{host}.{GetFqdnDomain(scope)}"; using (PsManager ps = new PsManager(fqdnHostName)) { ps.FailOverClusterNode(); } }
public void StartHostReadinessViaDCOM(string host, ref DataGridViewRow row, bool hasActiveResources) { DateTime lastBootDate = DateTime.MinValue; ServiceHostStatus automaticServicesStatus; DgvUtils.SetRowStyleForeColor(ref row, WUCollums.LastBoot, Color.Black); DgvUtils.SetRowValue(ref row, WUCollums.OperationResults, string.Empty); DgvUtils.SetRowValue(ref row, WUCollums.LastBoot, string.Empty); DgvUtils.SetRowValue(ref row, WUCollums.ServicesRunning, string.Empty); DgvUtils.SetRowValue(ref row, WUCollums.Cluster, false); try { DgvUtils.SetRowValue(ref row, WUCollums.LastBoot, "OS Connecting"); ManagementScope scope = GetWmiManagementScope(host); lastBootDate = GetLasBoot(scope); automaticServicesStatus = GetAutomaticServiceStatus(scope); DgvUtils.SetRowValue(ref row, WUCollums.LastBoot, lastBootDate.ToString("dd/MM/yyyy HH:mm")); DgvUtils.SetRowValue(ref row, WUCollums.Cluster, automaticServicesStatus.IsClustered); // Added as string to not broke the ordering in the Datagridview DgvUtils.SetRowValue(ref row, WUCollums.ServicesRunning, automaticServicesStatus.ServicesRunning.ToString()); if (hasActiveResources && automaticServicesStatus.IsClustered) { DgvUtils.SetRowValue(ref row, WUCollums.OperationResults, "Executing remote powershell..."); string fqdnHostName = $"{host}.{GetFqdnDomain(scope)}"; string resultOutput = string.Empty; int activeResourcesCount = 0; using (PsManager ps = new PsManager(fqdnHostName)) { activeResourcesCount = ps.GetActiveClusterResources().Count; resultOutput = $"Clustered resources qty: [{activeResourcesCount}]"; if (activeResourcesCount != 0) { resultOutput = $"{resultOutput} - Resource Names: [{string.Join(", ", ps.GetActiveClusterResources().ToArray())}]"; } DgvUtils.SetRowValue(ref row, WUCollums.OperationResults, resultOutput); } } } catch (Exception ex) { DgvUtils.SetRowStyleForeColor(ref row, WUCollums.LastBoot, Color.Red); DgvUtils.SetRowValue(ref row, WUCollums.LastBoot, ex.Message); } finally { EndReadiness(ref row); } }