Change Parameters of Windows Fail-Over Cluster with PowerShell

By | February 8, 2017

Configurations of a Windows Fail Over Cluster can be done entirely from the GUI but as we know this is valid for the simple setup. The GUI is limited to the easy cases, not for more uncommon cases. I already covered the case of the Active Directory Detached Cluster that can be created only using PowerShell command line, see https://blog.voina.be/deploy-windows-cluster-on-two-sites-with-only-one-domain-controller/
In case we want to change the already configured cluster again only some basic parameters can be changed from the GUI. Instead by using PowerShell we can virtually change any static parameter of the Cluster configuration.

To construct a script that can change any Cluster resource we have to follow the following steps. As an example I will change the static cluster IP.

STEP 1: Get a handle to the resource we want to change
This can be done by creating a PowerShell variable that holds a handle to the resource we want to change.

We can list the cluster resources by using the command:

Get-Cluster-Resource

The result is a table with a list of all resources:
Name — State — OwnerGroup — ResourceType

Now get a handle to of a resource in the shell variable $resource.

Get-ClusterResource resourceName

For example to get the handle of the cluster IP:

$resource = Get-ClusterResource "Cluster IP Address"

STEP 2: Display the changeable parameters of the resource

To display what parameters we can change in that resource we have the command:

Get-ClusterResource "Cluster IP Address" | Get-ClusterParameter

The result is a table with the parameters of this resource and their values.

STEP 3: Create the new parameter object
To be able to change the parameters of a resource we have to create some new parameter objects and then later set them to the cluster.

$parameter = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter resourceHandle,parameterName,parameterValue

For example lets change the “Address” and “SubnetMask” of the “Cluster IP Address” resource.

$parameter1 = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $res,Address,192.168.10.10 
$parameter2 = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $res,SubnetMask,255.255.255.0 
$parameterList = $parameter1,$parameter2 

STEP 4: Stop the resource to be changed
To be able to change the parameters of a resource first we have to stop the resource, maybe is safe to stop the whole cluster also.
To stop the cluster IP resource execute:

Stop-ClusterResource "Cluster IP Address"

Just to be safe stop the whole cluster if we are allowed to do it.

Stop-ClusterResource "My Cluster Name"

STEP 5: Set the new resource parameters
The last step is to commit the new resource parameters and check the result.
We have to send the new parameter objects to the Set-ClusterParameter command

$parameterList | Set-ClusterParameter

To check the result:

Get-ClusterResource "Cluster IP Address" | Get-ClusterParameter

Now start the resource :

Start-ClusterResource "Cluster IP Address"

In case the whole cluster was stopped start the cluster

Start-ClusterResource "My Cluster Name"

Now to check if all the cluster resources are online and started:

Get-ClusterResource resourceName

One thought on “Change Parameters of Windows Fail-Over Cluster with PowerShell

  1. cfizz34

    I am getting lots of failures when running this running powershell v

    Major Minor Build Revision
    —– —– —– ——–
    5 1 14409 1018

    Reply

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.