PowerShell for Failover Clustering: Find Clusters in a Domain

PowerShell for Failover Clustering: Find Clusters in a Domain

Rate This
  • Comments 5

Hi Cluster Fans,

 

Using PowerShell in Windows Server 2008 R2 Failover Clustering we have made it very easy to find all the clusters within a domain.

 

You may already know that you can use the Get-Cluster CMDlet to get information about the current cluster you are working on.  Beyond this, Get-Cluster also gives you the ability to find other clusters in your domain.

 

To find all the parameters, details and even examples of every CMDlet, you can run Get-Help CMDlet –Full

 

Let’s check out the output for the Get-Cluster parameter:

 

PS C:\Windows\system32> Get-Help Get-Cluster -Full

 

NAME

    Get-Cluster

 

SYNOPSIS

    Get information about one or more failover clusters in a given domain.

 

SYNTAX

    Get-Cluster [-Domain <string>] [<CommonParameters>]

    Get-Cluster [[-Name] <string>] [<CommonParameters>]

 

DESCRIPTION

    This cmdlet can obtain a variety of configuration and state information about a failover cluster, including the following items:

    - State information about whether a backup is in progress.

    - State information about whether the cluster is in a forced quorum state.

    - Cross-network settings that are especially relevant for multi-site clusters.

    To set a common property for the cluster, use this cmdlet to get the cluster object and then set the appropriate property on that cluster object directly.

 

PARAMETERS

    -Domain <string>

        Specifies the name of the domain to enumerate clusters in.

        Required?                    false

        Position?                    named

        Default value

        Accept pipeline input?       false

        Accept wildcard characters?  false

 

    -Name <string>

        Specifies the name of the cluster to get.

        Required?                    false

        Position?                    1

        Default value

        Accept pipeline input?       false

        Accept wildcard characters?  false

 

    <CommonParameters>

        This cmdlet supports the common parameters: Verbose, Debug, ErrorAction, ErrorVariable, WarningAction, WarningVariable, OutBuffer and OutVariable. For more information, type, "get-help about_commonparameters".

 

INPUTS

 

OUTPUTS

    Microsoft.FailoverClusters.PowerShell.Cluster

 

NOTES

 

    -------------------------- EXAMPLE 1 --------------------------

 

    C:\PS>Get-Cluster | fl *

 

    Domain                           : contoso.com

    Name                             : cluster1

    FixQuorum                        : 0

    SharedVolumesRoot                : C:\ClusterStorage

    DefaultNetworkRole               : 2

    Description                      :

    QuorumArbitrationTimeMax         : 20

    ClusSvcHangTimeout               : 60

    ClusSvcRegroupStageTimeout       : 7

    ClusSvcRegroupOpeningTimeout     : 5

    ClusSvcRegroupPruningTimeout     : 5

    ClusSvcRegroupTickInMilliseconds : 300

    HangRecoveryAction               : 3

    SameSubnetDelay                  : 1000

    CrossSubnetDelay                 : 1000

    SameSubnetThreshold              : 5

    PlumbAllCrossSubnetRoutes        : 0

    CrossSubnetThreshold             : 5

    BackupInProgress                 : 0

    RequestReplyTimeout              : 60

    WitnessRestartInterval           : 15

    SecurityLevel                    : 1

    ClusterLogLevel                  : 3

    ClusterLogSize                   : 100

    WitnessDatabaseWriteTimeout      : 300

    AddEvictDelay                    : 60

    EnableSharedVolumes              : Enabled

    Id                               : 655d3640-2845-4077-a396-9f317f2df60e

 

    Description

    -----------

    This command displays state and property information for the local cluster in the form of a list.

 

 

    -------------------------- EXAMPLE 2 --------------------------

 

    C:\PS>Get-Cluster cluster1

 

    Name

    ----

    cluster1

 

    Description

    -----------

    This command gets information about a cluster named cluster1.

 

 

    -------------------------- EXAMPLE 3 --------------------------

 

    C:\PS>Get-Cluster -domain contoso.com

 

    Name

    ----

    cluster1

    cluster2

    cluster3

 

    Description

    -----------

    This command gets information about each of the clusters in the contoso.com domain.

 

 

    -------------------------- EXAMPLE 4 --------------------------

 

    C:\PS>$cluster = Get-Cluster; $cluster.CrossSubnetDelay = 1500

 

    Description

    -----------

    This command sets the common property CrossSubnetDelay for the local cluster to 1500. Alternatively, you can run "Get-Cluster | %{ $_.CrossSubnetDelay = 1500 }" to set that property.

 

RELATED LINKS

    Online version: http://go.microsoft.com/fwlink/?LinkId=143782

    New-Cluster

    Remove-Cluster

    Start-Cluster

    Stop-Cluster

    Test-Cluster

 

 

As we can see from the third example, we already have the information we need to query all clusters in a domain!  We recommend checking out the help examples for the CMDlets if you want to figure out common operations for each.

 

Simply run Get-Cluster –domain MyDomain.com and you will get the list of clusters in that domain.

 

Don’t forget that you can also view this same help content online by using the –online switch: Get-Help Get-Cluster –online

 

Thanks,

Symon Perriman
Program Manager II
Clustering & High-Availability

Microsoft

Leave a Comment
  • Please add 5 and 5 and type the answer here:
  • Post
  • Symon,

    Do these cmdlets require your AD be at 2008 functional level, or can it work with domains that are still in a 2003 functional level?  Will this also discover Windows 2003 clusters?

    Thanks for clarifying.

    Rob

  • Hi Rob,

    This should work at the 2003 AD functional level, although I do not have the environment to try it out myself.  However keep in mind that in 2003 clustering, Kerberos is disabled by default, and the cluster will only create computer objects for Kerberos-enabled Network Names.  However in 2008+, Kerberos is on my default, so it will see all clusters in the domain, so this will work for all 2008 clusters.

    Thanks,

    Symon

  • Do you have to have the clustering role to get the cmdlet?  Could you run this on your windows 7 box?

    Where could I find the cmdlet?

  • Hi Mike,

    Yes, you need to import the clustering powershell module. PS > Import-Module FailoverClusters

    No, you cannot run it directly on your Win7 box as it does not have the clustering bits.  However it is remotable from other server boxes which support the clustering SKU.

    Click on the 'PowerShell' tag on this blog for our posts which include more information about using PowerShell with clustering.  The main Cluster PowerShell site is technet.microsoft.com/.../ee461009.aspx.

    Thanks,

    Symon Perriman

    Clustering | Microsoft

  • Hi,

    I have been trying to use the PS cmdlets and everything is working fine when I run them on a domain R2 machine, however, if I try to create a remote PS session from another computer, I always get the "You do not have administrative privileges on the cluster. Contact your network administrator to request access.

       Access is denied" error.

    My session script looks something like:

    $securePassword = ConvertTo-SecureString -AsPlainText -Force -String $password

    $Credential = New-Object System.Management.Automation.PSCredential $Username, $SecurePassword

    $s = new-PSSession -ComputerName $hostname -credential $credential

    enter-PSSession -Session $s

    import-module FailoverClusters

    User/credentials are the domain user the cluster was created with.

    I'd really appreciate some insight. Thanks.

Page 1 of 1 (5 items)