dm4ever,
Thank you for the response! Yes, I have tried all the WMI query methods, but they only work with Windows 2003 and not Windows 2000. Also, the WMI query does not return what I need.
However, I have figured out a function that will return the cluster name given the cluster node in the cluster. Below is what I have, and it works evevry time whether it is a Windows 2003 or a Windows 2000 cluster.
strComputer = "MyServer"
strDomain = "MyDomain"
Wscript.Echo getClusterName(strComputer, strDomain)
' Function to get cluster name given a cluster node.
Private Function getClusterName(strComputer, strDomain)
Dim objCluster, objItem, i, objClusterApp, colClusters
Dim j, strClusterName, objClusterCon, objResGroupName
Dim strResGroupName, strActiveNode, strClustNodes
On Error Resume Next
Set objCluster = CreateObject("MSCluster.Cluster")
objCluster.Open strComputer
For Each objItem In objCluster.Nodes
ReDim Preserve arrClustNode(i)
arrClustNode(i) = objItem.Name
i = i + 1
Next
If i < 2 Then
getClusterName = "Not Cluster Member"
Exit Function
Else
arrClustNode = SortItem(arrClustNode)
For Each objItem In arrClustNode
strClustNodes = strClustNodes & vbTab & objItem
Next
Set objClusterApp = CreateObject("MSCluster.ClusApplication")
Set colClusters = objClusterApp.ClusterNames(strDomain)
For j = 1 To colClusters.Count
strClusterName = colClusters.Item(j)
Set objClusterCon = CreateObject("MSCluster.Cluster")
objClusterCon.Open(strClusterName)
For Each objResGroupName In objClusterCon.ResourceGroups
strResGroupName = objResGroupName.Name
strActiveNode = objClusterCon.ResourceGroups.Item(strResGroupName).OwnerNode.Name
For Each objItem In arrClustNode
If UCase(objItem) = UCase(strActiveNode) Then
getClusterName = strClusterName & vbTab & strClustNodes
Exit Function
End If
Next
Next
Next
End If
Err.Clear
On Error Goto 0
' Clean up.
Set objCluster = Nothing: Set objClusterApp = Nothing
Set colClusters = Nothing: Set objClusterCon = Nothing
End Function
'Function to sort the array.
Function SortItem(arrSort)
Dim k, j, Temp
For k = UBound(arrSort) - 1 To 0 Step - 1
For j= 0 To k
'Case insensitive compare.
If LCase(arrSort(j)) > LCase(arrSort(j+1)) Then
Temp = arrSort(j+1)
arrSort(j+1) = arrSort(j)
arrSort(j) = Temp
End If
Next
Next
SortItem = arrSort
End Function
CluM09