Check the active node of a cluster

User avatar
daniel
Site Admin
Posts: 217
Joined: Tue Jan 09, 2007 9:54 pm
Contact:

Check the active node of a cluster

Postby daniel » Fri Jul 29, 2011 5:40 am

Hello,

Hereby a script which allows you to retrieve the name of the active node:

Code: Select all

Get-WmiObject -Class Win32_ComputerSystem -ComputerName Cluster01 | Select-Object Name


Replace "Cluster01" with the name of your services

:D

Darco
Site Admin
Posts: 80
Joined: Tue Jan 09, 2007 10:03 pm

Postby Darco » Fri Jul 29, 2011 5:52 am

Just for the fun, hereby the vbs version.

See the differences in lines

Code: Select all

Set args = WScript.Arguments

resourcename = args.Item(0)

strClusterWMINameString = "winmgmts:\\" & resourcename & "\root\cimv2"
Set objWMISvc = GetObject( strClusterWMINameString )
Set colItems = objWMISvc.ExecQuery( "Select * from Win32_ComputerSystem", , 48 )

For Each objItem in colItems
strComputerName = objItem.Name
WScript.Echo "The Cluster " & resourcename & " active node is " & strComputerName
Next


:idea:

Darco
Site Admin
Posts: 80
Joined: Tue Jan 09, 2007 10:03 pm

Postby Darco » Fri Jul 29, 2011 7:54 am

Another script with same result 8)

Code: Select all

$servername = "Server01"
$Clu = New-Object -com "MSCluster.Cluster"
$Clu.Open($ServerName)
$GroupOwner = $Clu.ResourceGroups.Item($ServerName).OwnerNode.Name

User avatar
daniel
Site Admin
Posts: 217
Joined: Tue Jan 09, 2007 9:54 pm
Contact:

Postby daniel » Fri Jul 29, 2011 7:59 am

hehe

Here another VBS version :P

Code: Select all

strServerName = "Server01"

Set objCluster = GetObject("MSCluster.Cluster")
objCluster.Open(strServerName)

Wscript.Echo objCluster.ResourceGroup.Item("Cluster Group").OwnerNode.Name


:D :lol:


Return to “PowerShell”

Who is online

Users browsing this forum: No registered users and 1 guest