PowerShell for Failover Clustering: Let’s Rename a Few Things

PowerShell for Failover Clustering: Let’s Rename a Few Things

Rate This
  • Comments 1

Hi Cluster fans,

In this blog post, I’ll walk you through how to rename a couple of objects in your failover clusters using the new PowerShell CMDlets we’ve introduced in Windows Server 2008 R2.

Trying to rename a cluster group in the GUI is easy, just right-click on the group, rename, enter the new name, and you’re done:

If you’re trying to do the same thing via PowerShell, you might guess Rename-ClusterGroup, right? Well, not really. We could’ve done it that way, but where would the fun be! J. No seriously, cluster objects have identifiers represented as GUIDs, and the name of a cluster object is nothing but an attribute:

PS G:\Windows\system32> Get-ClusterGroup

Name                    OwnerNode                State

----                    ---------                -----

temp1                   ahmedbc1-n1              Online

temp4                   ahmedbc1-n1              Online

Cluster Group           ahmedbc1-n1              Online

Available Storage       ahmedbc1-n1              Offline

 

PS G:\Windows\system32> Get-ClusterGroup temp1 | fl Name,Id

Name : temp1

Id   : cc5df8e6-0e99-4c94-8210-3e6bc9c490dd

 

So, instead of exposing a Rename CMDlet for each of our rename-able (is that even a word?) objects, we decided to make the Name attribute for each of those objects configurable.  As a result, renaming objects in a failover cluster via PowerShell is as easy as setting the Name member on the .NET object returned by one of our Get CMDlets. For example, for a cluster resource group:

PS G:\Windows\system32> Get-ClusterGroup temp4 | %{ $_.Name = "temp2" }

Or, if you’re more comfortable with this format:

PS G:\Windows\system32> ( Get-ClusterGroup temp4 ).Name = "temp2"

Or, if you want to keep reference to the object (in case you want perform an operation on it later, for example), you can break this up into two steps:

PS G:\Windows\system32> $group = Get-ClusterGroup temp4

PS G:\Windows\system32> $group.Name = "temp2"

 

And, the group is renamed:

PS G:\Windows\system32> Get-ClusterGroup

Name                       OwnerNode              State

----                       ---------              -----

temp1                      ahmedbc1-n1            Online

temp2                      ahmedbc1-n1            Online

Cluster Group              ahmedbc1-n1            Online

Available Storage          ahmedbc1-n1            Offline

 

Now, renaming a cluster resource is not any different:

PS G:\Windows\system32> Get-ClusterGroup temp2 | Get-ClusterResource

Name                State         Group         ResourceType

----                -----         -----         ------------

IP Address 157.5... Online        temp2         IP Address

IP Address 2001:... Online        temp2         IPv6 Tunnel Address

IP Address 2001:... Online        temp2         IPv6 Tunnel Address

IP Address 2001:... Online        temp2         IPv6 Address

temp4               Online        temp2         Network Name

 

PS G:\Windows\system32> Get-ClusterResource temp4 | %{ $_.Name = "newname" }

PS G:\Windows\system32> Get-ClusterGroup temp2 | Get-ClusterResource

 

Name                State         Group         ResourceType

----                -----         -----         ------------

IP Address 157.5... Online        temp2         IP Address

IP Address 2001:... Online        temp2         IPv6 Tunnel Address

IP Address 2001:... Online        temp2         IPv6 Tunnel Address

IP Address 2001:... Online        temp2         IPv6 Address

newname             Online        temp2         Network Name

 

If you’re following so far, and if you’re double checking everything I say by looking at the Failover Cluster Manager UI, keep in mind that when the Failover Cluster Manager displays information, it doesn’t necessarily display the resource name on the list of resources, if there are other attributes in that cluster resource that are more important than the resource name. Network name resources like the one I used in my command above are a good example, as the DNS name of the network name resources are much more interesting in the GUI experience.

 

Just look at the properties for that resource to get the name of the resource:

 

 

One final rename we’ll do is renaming the cluster. In the GUI you can do this on the properties of the cluster:

 

 

In PowerShell, just like before with groups and resources:

PS G:\Windows\system32> Get-Cluster

Name

----

ahmedbc12

 

 

PS G:\Windows\system32> Get-Cluster | %{ $_.Name = "ahmedbc12new" }

PS G:\Windows\system32> Get-Cluster

 

Name

----

ahmedbc12new

 

And, notice how that automatically changes the cluster name resource in the cluster group:

PS G:\Windows\system32> Get-ClusterResource "Cluster Name" | Get-ClusterParamete

r

 

Object              Name          Value               Type

------              ----          -----               ----

Cluster Name        Name          AHMEDBC12NEW        String

Cluster Name        DnsName       ahmedbc12new        String

...

 

Have fun!

Ahmed Bisht

Senior Program Manager

Clustering & High-Availability

Microsoft
Leave a Comment
  • Please add 4 and 1 and type the answer here:
  • Post
  • It is throwing the error

    Exception setting "Name": "An error occurred while renaming the cluster 'xxx'."

    At line:1 char:18

    + Get-Cluster | %{ $_.Name="sss" }

    +                  ~~~~~~~~~~~~~~~~~~~~~~

       + CategoryInfo          : NotSpecified: (:) [], SetValueInvocationException

       + FullyQualifiedErrorId : ExceptionWhenSetting

Page 1 of 1 (1 items)