How to use Powershell in Failover Clustering–Part 1
Powershell is a really powerful toy for any Windows administrator where tasks need to be automated and or repeated several times.
Here I would like to start an blog series of how to use Powershell in Windows Server Failover Cluster (WSFC) environments.
Let’s start over with some basic commandlet’s to get status of clustered groups, resources and cluster core resources, move groups and soon. Later we will do some advanced operations with Powershell.
The WSFC Powershell (CLI) interface is everywhere available where WSFC feature is installed:
- Windows Server 2008 R2 (SP1)
- Core (not installed by default)
- Microsoft Hyper-V Server 2008 R2 (SP1)
- Remote Server Administration Tools (RSAT) for Windows 7 (SP1)
First of all, you must import the “FailoverCluster” module to get the commandlet’s. To get a list of all available modules you can use:
PS:\ Get-Module -ListAvailable
To import the module you need to use “Import-Module” commandlet:
PS:\ Import-Module FailoverClusters
YUHUU We have now the full set of all Failover Cluster commandlet’s available, let’s have a look which they are:
PS:\ Get-Command –Module FailoverClusters or Get-Command | findstr Cluster
As you can see, there are for the most of the GUI actions an cmdlet available, sometimes more. In total there are 69 Failover Cluster specific cmdlet’s which gives you many many *creative* usage ways.
NOTE: A really helpful method with Powershell is the Get-Help cmdlet:
Built-in help: Get-Help cmdlet -Full Examples:
Get-Help cmdlet –Examples Online help (INET connection is required):
Get-Help cmdlet –Online
Let’s start with some easy commandlet to do some basic operations:
How to get a list of all clustered groups via Powershell?
As you can see I do have some resources offline. Let’s bring them online
How to bring online a Cluster Group via Powershell?
Now, let’s move a group to a different node to balance the workloads in my *test* cluster
How to move a cluster group via Powershell?
PS:\ Move-ClusterGroup “GROUPNAME” –Node “NODENAME”
How to get a list of all clustered resources via Powershell?
How to get a list of all clustered groups from an node via Powershell?
PS:\ Get-ClusterNode –Name “NODENAME” | Get-ClusterGroup
How to get a list of all clustered resources within a cluster group via Powershell?
PS:\ Get-ClusterGroup "GROUPNAME" | Get-ClusterResource
How to get more parameters from a clustered disk (resource)?
PS:\ Get-ClusterResource "Cluster Disk 1" | Get-ClusterParameter
How can I test/validate my cluster via Powershell?
Since R2 you can also validate your cluster via CLI Powershell:
PS:\ Get-Help Test-Cluster
A.e.: PS:\ Test-Cluster –Node Node1,Node2
A list of all available Test-Cluster scenarios - which can be *in-/excluded*- can you find here:
Hope this has opened your interest in more around Powershell for Failover Clustering - stay tuned for more or start with playing with PS…..
Some additional reference can you find here:
Mapping Cluster.exe Commands to Windows PowerShell Cmdlets for Failover Clusters
PowerShell Quick Reference
Clustering with PowerShell
PowerShell for Failover Clustering: Finding the Drive Letter
PowerShell for Failover Clustering: Understanding Error Codes
PowerShell for Failover Clustering: Frequently Asked Questions