Managing Windows failover clusters using PowerShell

The complete operation of Windows failover clusters can be managed using PowerShell. PowerShell not only reduces the time it takes to perform tasks using the GUI, but also enables automation. For example, in case you need to perform a failover cluster operation task every day, you can find a failover PowerShell cmdlet that can help you perform the required tasks automatically using a scheduled task. This article explains how to import Windows failover cluster PowerShell modules and how to use the available PowerShell cmdlets to manage Windows failover clusters.

Importing Windows failover cluster PowerShell cmdlets

cross-platform powershell

Windows Server implements the “FailoverClusters” Windows PowerShell module library, which provides PowerShell cmdlets to work with Windows failover clusters. When you enable the failover cluster role on a Windows Server, the installation process installs the required Windows failover cluster PowerShell modules. Before you can execute any of the Windows failover PowerShell cmdlets, you will be required to import the modules in a PowerShell session by executing the “Import-Module” command as shown in the command below:

  1. Launch Windows PowerShell with administrator privileges from the Start Menu.
  2. To import the Windows failover cluster module, type the following cmdlet:

Import-Module failoverclusters
Tip: In case you would like PowerShell to import the failover cluster module every time you run PowerShell, you can do so by modifying the Windows PowerShell profile.

Listing Windows failover cluster PowerShell cmdlets

There are PowerShell cmdlets available to work with different aspects of a Windows failover cluster. For example, you can use Add-ClusterDisk PowerShell cmdlet to add a cluster disk in a failover cluster. Similarly, the Add-ClusterSharedVolume PowerShell cmdlet can be used to add a CSV volume to the failover cluster. To get a list of failover cluster PowerShell cmdlets, use this command:

Get-Command –Module FailoverClusters

The above command will list all the PowerShell cmdlets that are available in the FailoverClusters module. There are PowerShell cmdlets that help you collect information from a Windows failover cluster. There are a few PowerShell cmdlets that you can use to process modifications in a Windows failover cluster and there are PowerShell cmdlets available that can be used to perform deletion operations in the failover clusters.

Testing a failover cluster using PowerShell

You may find it necessary to run validation tests against a Windows failover cluster every week or so to ensure the failover cluster is operating normally. You can use Windows Failover Cluster Manager to run the validation tests and provide you with a detailed report, but rather than using the Cluster Manager GUI you can use Test-Cluster PowerShell cmdlet. The tests will be captured in a file that you will specify when you run the Test-Cluster PowerShell command. The Test-Cluster cmdlet supports multiple types of tests such as cluster test, inventory, network, storage, and a few system tests.

Testing system and cluster drivers

In case you need to verify that ensure system and cluster drivers are using the correct version, just execute this PowerShell command:

Test-Cluster –Include “List System Drivers”, “List Unsigned Drivers”

Clearing cluster configuration of an evicted node

You may find the Clear-ClusterNode PowerShell cmdlet useful if you need to remove the complete configuration of a node that was evicted from the cluster. Sometimes it is necessary to ensure that all the configuration information for the evited node has been removed from the cluster. Execute this command with “-Force” switch:

Clear-ClusterNode PRDNode1 –Force

The “-Force” parameter in this command ensures that the information pertaining to PRDNode1 is removed from the cluster.

The most common PowerShell cmdlets that you would want to use are Test-Cluster to validate a cluster as explained in above in this article, Update-ClusterVirtualMachineConfiguration to update virtual machine configuration that are operating in a cluster, Set-ClusterLog to set the cluster log levels, Get-ClusterQuorum to get cluster quorum configuration information, and Get-ClusterLog for troubleshooting cluster-related issues.

Starting with Windows Server 2012 R2, the complete operation of the cluster can be managed using the failover PowerShell cmdlets.

About The Author

1 thought on “Managing Windows failover clusters using PowerShell”

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