Here is a small cmdlet I wrote to get the currently active node in a Windows cluster:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
function Get-ClusterActiveNode { <# .SYNOPSIS Returns the active server node name for the specified Windows server cluster. .DESCRIPTION Returns the active server node name for the specified Windows server cluster. .EXAMPLE PS C:\> Get-ClusterActiveNode -ClusterCName ClusterAlias .PARAMETER ClusterName Specifies the cluster name or alias for the Windows cluster to query. .OUTPUTS The output is displayed to the console. #> [CmdletBinding(DefaultParameterSetName = 'ClusterName')] [OutputType([string], ParameterSetName = 'ClusterName')] [OutputType([string])] Param ( [Parameter(Mandatory = $true, Position = 0)] [string]$ClusterName ) try { Get-WmiObject -Class Win32_ComputerSystem -ComputerName $ClusterName | Select-Object @{ Label = "Active Node"; Expression = { $_.Name } } } catch { $exception = $_.Exception "Error attempting to retrieve cluster node information for cluster name\alias: $ClusterName" Write-Error "$exception.Message" Write-Error $exception.InnerException Write-Error $exception.Data Write-Error $exception.StackTrace } } |
Using the cmdlet as displayed below:
Views – 2032