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)
- Full
- 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?
PS:\ Get-ClusterGroup
As you can see I do have some resources offline. Let’s bring them online
How to bring online a Cluster Group via Powershell?
PS:\ Start-ClusterGroup “GROUPNAME” ![]()
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?
PS:\ Get-ClusterResource
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
http://technet.microsoft.com/en-us/library/ee619744(WS.10).aspx
PowerShell Quick Reference
http://www.microsoft.com/downloads/details.aspx?FamilyId=DF8ED469-9007-401C-85E7-46649A32D0E0&displaylang=en
Clustering with PowerShell
http://technet.microsoft.com/en-us/library/ee619751(WS.10).aspx
PowerShell for Failover Clustering: Finding the Drive Letter
http://blogs.msdn.com/b/clustering/archive/2009/10/16/9908325.aspx
PowerShell for Failover Clustering: Understanding Error Codes
http://blogs.msdn.com/b/clustering/archive/2010/04/28/10003627.aspx
PowerShell for Failover Clustering: Frequently Asked Questions
http://blogs.msdn.com/b/clustering/archive/2009/05/23/9636665.aspx
Regards
Ramazan Can
Tags: CLI, Failover Cluster Powershell, Powershell, Powershell Function. Scripting
August 10, 2011 at 05:25 |
[...] is an article on managing the Failover Clustering using PowerShell – How to use PowerShell in Failover Clustering–Part 1. This article however is how to setup and configure Failover Clustering and also how to add [...]
October 29, 2011 at 01:56 |
I had no idea how effective a smaller server core is at reducing security breaches. Something I’ve got to keep in mind in the future.
September 17, 2012 at 12:18 |
Hi Ramazan,
We have 2nodes windows 2008R2 cluster,where SQL & SAP database is running, last 3 months we are facing very poor performance.sometimes windows cluster is going hangs,we have already logged the call with Microsoft,but we have not getting any solution, your help will be appreciate..
September 17, 2012 at 20:18 |
Hi Shan,
Generally performance issues to analyze are really hard in a forum as there is a broad range of involved areas where a bottleneck can sit
especially in SQL areas where I/O plays a key role I would generally start looking on disk que lengths, just to make sure before digging deeper into root cause analyses….
Let me know if you have any further question on this
Ramazan Can
January 30, 2013 at 21:51 |
I am unable to load the failover cluster module on my Win 7 machine because it isn’t listed. I’ve installed RSAT SP1 and have enabled the Failover Clustering Tools feature. I can see/access the Failover Cluster Manager gui in my admin tools folder. I have the x64 version of Win 7 installed on my system. I disabled and re-enabled the Failover Clustering Tools feature and I still can’t see the FailOver module when I run Get-Module -ListAvailable. It just isn’t there.
What am I missing?
March 18, 2013 at 19:53 |
right – this is “by design”
Failover cluster powershell module rely on Failover cluster service which isnt available on your WIn7 box. you can workaround and powershell into a node with “New-PSSession” and use there FC module.
Hope that helps
Ramazan