Powershell · 2016-03-20

PowerShell – Find Active Node On Cluster

PowerShell script that prints out the state of the node you are on – Active or Passive.

Microsoft Failover Cluster Documentation For PowerShell

This script only works on a clustered environment on Windows 2008 R2/2012. This does not work on Windows 7. If you’re on a Windows 7 machine then you must RDP into a server with the required services and OS. For more information, see the related TechNet article.

Import-Module failoverclusters
$activeNode = Get-ClusterGroup|Select OwnerNode -unique #OR #$activeNode = Get-ClusterGroup -Cluster (Get-Cluster)|Select OwnerNode -unique
$passiveNode = Get-ClusterNode|Select Name|Where-Object {$_.name -ne $activeNode.OwnerNode}
$thisNode = Get-Content env:COMPUTERNAME

if($activeNode.OwnerNode.Name -eq $thisNode){ echo "Active"}else{ echo "Passive"}