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

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.

Nirmal Sharma

Nirmal Sharma is a MCSEx3, MCITP and was awarded the Microsoft MVP award in Directory Services and Windows Networking. He specializes in Microsoft Azure, Office 365, Directory Services, Failover Clusters, Hyper-V, PowerShell Scripting and System Center products. Nirmal has been involved with Microsoft Technologies since 1994. In his spare time, he likes to help others and share some of his knowledge by writing tips and articles on various sites.

Published by
Nirmal Sharma
Tags Powershell

Recent Posts

Moving data from an Azure VM to Storage Account with AzCopy

Here’s an elegant and modern way to move data from your Azure virtual machine to…

2 hours ago

A lot not to like: Analysis of recent Facebook data breach

The effects of the recent Facebook data breach are still being felt. In this new…

6 hours ago

Exchange 2019: Building an environment from scratch

Are you finally ready to take the plunge into Exchange 2019? If you are building…

9 hours ago

Cyber-extortion scheme targets Google AdSense users

A cyber-extortion scam targeting Google’s AdSense users is making waves. Here are the facts that…

1 day ago

Need to check your Azure VM costs? Use this script

Nobody likes a surprise in their cloud bills. This handy script will help you check…

1 day ago

Updating and extending PowerShell object’s type data

This neat PowerShell tip will help you write more efficient scripts by showing you how…

1 day ago