PowerShell quick hits: Cmdlets and scripts for managing Windows Failover

Microsoft provides PowerShell commands for all roles and features including Windows Failover. Windows Failover can be managed using Failover Cluster Manager as well as PowerShell cmdlets that ship with the Windows Failover Cluster feature. Managing repeated Failover Cluster tasks make life easier for administrators. For example, in case you need to check the status of cluster resources to ensure that resources are up and running and working as expected, you can develop a tiny PowerShell script that helps you check the status of critical Failover Cluster resources. Similarly, you might want to use PowerShell to perform daily maintenance tasks associated with Windows Failover Cluster. In this article, we will provide an overview of how to install Failover Cluster modules and a few PowerShell commands to interact with the failover cluster and its resources.

How to Install Windows Failover Cluster modules

By default, when you install the Windows Failover Cluster feature, the PowerShell modules for Failover Cluster get installed automatically. However, you can verify that the Failover Cluster modules are installed by using the commands below. Executing the command below in a PowerShell prompt will report the status of Failover Cluster modules.

Get-Module –ListAvailable

Running the PowerShell command below will import the Failover Cluster modules in the current PowerShell session.

Import-Module FailoverClusters

Tip: You might need to run Import-Module command on a management computer from which you would like to manage Windows Failover Clusters.

To ensure that the cluster modules are imported successfully in the current PowerShell session, execute the command below, which will verify the existence of modules that have a “cluster” string associated with them.

Get-Command –Module FailoverClusters or Get-Command | FindStr Cluster

Once your computer is set up with Failover Cluster modules, you can execute the available PowerShell cmdlets to interact with Failover Cluster and its resources. Let’s take a look at some examples.

Getting cluster information

It is easy as pie to get cluster-specific information by using Get-Cluster PowerShell cmdlet. All you need to do is execute this command in an elevated PowerShell prompt:

Get-Cluster | Format-List –Property *

While the above command gets cluster information from the local cluster, the command below gets all clusters operating in an Active Directory domain:

Get-Cluster –Domain TechGenix.com

If you have many Windows Failover Clusters operating in an Active Directory domain and would like to verify cluster log level and cluster size to ensure settings have been configured according to best practices, you can use this PowerShell script:

$Clusters = “C:\Temp\AllClusters.CSV”
ForEach ($ThisCluster in $Clusters)
Get-Cluster –Name $ThisCluster -Properties ClusterLogLevel, ClusterLogSize

Windows Failover

Before you can use the above script, make sure to add cluster names per line in C:\Temp\AllClusters.CSV file.

To quickly check the status of all resources in a Windows Failover cluster, you can use Get-ClusterResource PowerShell cmdlet. For each cluster resource, Failover Cluster implements “State” property, which provides the resource status. A healthy resource will always be shown as “Online.” To check the status of all resources, just execute this PowerShell command:


If you just would like to see the cluster resource name and its status, use this PowerShell script.

$AllResources = Get-ClusterResource
ForEach ($ThisResource in $AllResources)

If you need to report a message in the PowerShell prompt, you can set a condition in the above PowerShell script that checks the State property value and reports only if a resource is not online. For example, this script will report the cluster resource name and a message indicating that the resource is not online:

$AllResources = Get-ClusterResource
ForEach ($ThisResource in $AllResources)
$ThisRC = $ThisResource.Name
$ThisRCS = $ThisResource.State
IF ($ThisRCS -ne “Online”)
Write-Host “WARNING : Cluster Resource $ThisRC is NOT ONLINE”

windows failover2

In case you need to see the status of all resources in a specific Cluster group, using Get-ClusterGroup along with Get-ClusterResource will do the job as highlighted in the command below:

Get-ClusterGroup –Name <ClusterGroupNameHere> | Get-ClusterResource

Let’s assume you would like to see the status of all cluster nodes to ensure they are operating normally. Similar to cluster resources, Failover Cluster implements “State” property for cluster nodes. The “State” property for a cluster node indicates its status. By executing the command below, you are going to see the “State” property value for all nodes operating in a cluster:

Get-ClusterNode | FT Name, State

If you need to see the status of all nodes in a specific cluster, execute this PowerShell command:

Get-ClusterNode –Cluster <ClusterNameHere> | FT Name, State

If you wish to see the resources owned by a particular node, execute this PowerShell command:

Get-ClusterNode –Name PRDNode1 | Get-ClusterResource | Export-CSV C:\Temp\NodeResources.CSV

The command above will report cluster resources owned by PRDNode1 and also save the output to c:\Temp\NodeResources.CSV file.

There are many PowerShell cmdlets for use with Windows Failover Clusters. You can search for available cmdlets by using the Get-Command FailoverClusters and then look for the cmdlet that can help you save time to execute a task that you usually perform using the Failover Cluster Manager.

Featured image: Shutterstock

About The Author

1 thought on “PowerShell quick hits: Cmdlets and scripts for managing Windows Failover”

Leave a Comment

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

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Scroll to Top