Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Discovery.ScriptDataSource.Legacy (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource System.Discovery.Scheduler Default
VbProbe ProbeAction Microsoft.Windows.ScriptDiscoveryProbe Default

Overrideable Parameters:

IDParameterTypeSelector
IntervalSecondsint$Config/IntervalSeconds$
LogSuccessEventbool$Config/LogSuccessEvent$
ScriptGroupIdstring$Config/ScriptGroupId$
TimeoutSecondsint$Config/TimeoutSeconds$

Source Code:

<DataSourceModuleType ID="Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Discovery.ScriptDataSource.Legacy" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="IntervalSeconds" type="xsd:int"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="LogSuccessEvent" type="xsd:boolean"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ScriptGroupId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="MPElementID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetID" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetComputer" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ClusterName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TimeoutSeconds" type="xsd:int"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="LogSuccessEvent" Selector="$Config/LogSuccessEvent$" ParameterType="bool"/>
<OverrideableParameter ID="ScriptGroupId" Selector="$Config/ScriptGroupId$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DS" TypeID="System!System.Discovery.Scheduler">
<Scheduler>
<SimpleReccuringSchedule>
<Interval Unit="Seconds">$Config/IntervalSeconds$</Interval>
</SimpleReccuringSchedule>
<ExcludeDates/>
</Scheduler>
</DataSource>
<ProbeAction ID="VbProbe" TypeID="Windows!Microsoft.Windows.ScriptDiscoveryProbe">
<ScriptName>Microsoft.Windows.Server.DiscoverClusterDisks.vbs</ScriptName>
<Arguments>$Config/LogSuccessEvent$ "$Config/ScriptGroupId$" "$Config/MPElementID$" "$Config/TargetID$" "$Config/TargetComputer$" "$Config/ClusterName$"</Arguments>
<ScriptBody><Script>
Option Explicit

Const SCRIPT_VERSION = "1.05"
Const LOG_SUCCESS_EVENT_PARAMETER_NAME = "LogSuccessEvent"
Const MP_ELEMENT_PARAMETER_NAME = "MP Element"
Const MANAGED_ENTITY_ID_PARAMETER_NAME = "Managed Entity"
Const TARGET_COMPUTER_PARAMETER_NAME = "Target Computer"
Const CLUSTER_NAME_PARAMETER_NAME = "Cluster Name"

'WMI constants
Const WMI_MSCLUSTER_NAMESPACE = "root\MSCluster"
Const WMI_CIMV2_NAMESPACE = "root\cimv2"
Const WMI_MSCLUSTER_CLUSTER_CLASS = "MSCluster_Cluster"
Const WMI_MSCLUSTER_CLUSTER_RESOURCE = "MSCluster_Resource"
Const WMI_CLUSTER_RESOURCE_TO_DISK_ASSOCIATOR_CLASS = "MSCluster_ResourceToDisk"
Const WMI_CLUSTER_DISKPARTITION_TO_DISK_ASSOCIATOR_CLASS = "MSCluster_DiskToDiskPartition"

Const WMI_MSCLUSTER_RESOURCEGROUP = "MSCluster_ResourceGroup"
Const WMI_MSCLUSTER_RESOURCEGROUP_TO_RESOURCE = "MSCluster_ResourceGroupToResource"
Const WMI_NAME_PROPERTY_NAME = "Name"
Const WMI_PATH_PROPERTY_NAME = "Path"
Const WMI_FILESYSTEM_PROPERTY_NAME = "FileSystem"
Const WMI_TOTALSIZE_PROPERTY_NAME = "TotalSize"
Const WMI_VOLUMELABEL_PROPERTY_NAME = "VolumeLabel"


'Event constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

Const EVENT_ID_SUCCESS = 1000 'Use IDs in the range 1 - 1000
Const EVENT_ID_SCRIPTERROR = 999 'Then you can use eventcreate.exe to test the MP

Const SCRIPT_SUCCESS = 0
Const SCRIPT_WITH_ERROR = 1

'Global vars
Dim mblnLogSuccessEvent 'As Boolean
Dim mstrIdentifier 'As String
'On Error Resume Next

Call Main

'*********************************************************************************************
' PROCEDURE: Main
' DESCRIPTION: Reads the script parameters and creates the cluster disks discovery data.
' PARAMETERS: void
'*********************************************************************************************
Private Sub Main()

' Targeted at Microsoft.Windows.Cluster.VirtualServer (based on Microsoft.Windows.Server.Computer)
Dim strSourceID 'As String '= oArgs(4). strSourceId is the GUID of the discovery object that runs the script (MPElement).
Dim strManagedEntityId 'As String '= oArgs(5) - strManagedEntityId is the GUID of the computer class that is targeted by the script (Target/Id).
Dim strTargetComputer 'As String '= oArgs(6)
Dim strClusterGroupName 'As String '= oArgs(7)
Dim objMomScriptAPI 'As MOM.ScriptAPI
Dim objDiscoveryData 'As DiscoveryData
Dim intSuccess 'As Integer
Dim strErrorMessage
Dim strClusterName


Call SetLocale("en-us")
On Error Resume Next
Err.Clear
Set objMomScriptAPI = CreateObject("MOM.ScriptAPI")

If Err.Number &lt;&gt; 0 Then
WScript.Quit(-1)
End If

If Not GetClusterName(strClusterName) Then
WScript.Quit(-1)
End If

If Not GetScriptParameters(strSourceID, strManagedEntityId, strTargetComputer, strClusterGroupName) Then
' If the script is called without the required arguments,
' create an information event and then quit.
strErrorMessage = "-- Cluster Disks Discovery Script -- The script was called with fewer than six arguments or the arguments could not be parsed."
Call LogScriptEvent(0, EVENT_ID_SCRIPTERROR, EVENT_TYPE_WARNING, strErrorMessage,objMomScriptAPI)
Set objMomScriptAPI = Nothing

WScript.Quit (-1)
End If

Set objDiscoveryData = objMomScriptAPI.CreateDiscoveryData(0, strSourceID, strManagedEntityId)
If Err.Number &lt;&gt; 0 Then
strErrorMessage = "-- Cluster Disks Discovery Script -- Cannot create Discovery Data object."
Call LogScriptEvent(0, EVENT_ID_SCRIPTERROR, EVENT_TYPE_WARNING, strErrorMessage,objMomScriptAPI)

Set objDiscoveryData = Nothing
Set objMomScriptAPI = Nothing
WScript.Quit(-1)
End If

'Discover instances
intSuccess = DiscoverClusterDisks(strTargetComputer, strClusterName,strClusterGroupName, objDiscoveryData)
If intSuccess = SCRIPT_SUCCESS Then
If mblnLogSuccessEvent Then
strErrorMessage = "-- Cluster Disks Discovery Script -- Script executed successfully."
Call LogScriptEvent(0, EVENT_ID_SUCCESS, EVENT_TYPE_INFORMATION, strErrorMessage,objMomScriptAPI)

End If

'Return discovery data
Call objMomScriptAPI.Return(objDiscoveryData)
Else
strErrorMessage = "-- Cluster Disks Discovery Script -- An error occurred while running the script."
Call LogScriptEvent(0, EVENT_ID_SUCCESS, EVENT_TYPE_INFORMATION, strErrorMessage,objMomScriptAPI)

End If

Set objDiscoveryData = Nothing
Set objMomScriptAPI = Nothing
On Error Goto 0
End Sub



'****************************************************************************************************************
' FUNCTION: DiscoverClusterDisks
' DESCRIPTION: Discover instances of the class 'Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk' using WMI.
' PARAMETERS: IN String strTargetComputer: principal name of the targeted 'Microsoft.Windows.Cluster.VirtualServer' instance.
' IN String strClusterName: the cluster containing the cluster shared volume
' OUT Object objDiscoveryData: initialised DiscoveryData instance
' RETURNS: Integer: 0 if successful and 1 if fails
'****************************************************************************************************************
Private Function DiscoverClusterDisks(ByRef strTargetComputer, ByRef strClusterName,ByRef strClusterGroupName, ByRef objDiscoveryData) 'As Integer

Dim objMSClusterSWbemServices 'As SWbemServices
Dim objClusterResources 'As SWbemObject
Dim objClusterResource 'As SWbemObject
Dim objClusterDisk 'As SWbemObject
Dim objClusterDisks 'As SWbemObject
Dim objClusterDiskPartition 'As SWbemObject
Dim objClusterDiskPartitions 'As SWbemObject
Dim intSuc 'As Integer

Dim objResourceGroups
Dim objResourceGroup

DiscoverClusterDisks = SCRIPT_WITH_ERROR

'Connect to WMI NS \\.\root\MSCluster
If Not ConnectToWbemNS(".", WMI_MSCLUSTER_NAMESPACE, objMSClusterSWbemServices) Then
Exit Function
End If

If Not GetClusterGroup(strTargetComputer, strClusterGroupName, objMSClusterSWbemServices, objResourceGroups) Then
Exit Function
End If

On Error Resume Next
Err.Clear

For Each objResourceGroup In objResourceGroups
If (Err.Number &lt;&gt; 0) Then
Set objResourceGroups = Nothing
Exit Function
End If

Set objClusterResources = objResourceGroup.Associators_(WMI_MSCLUSTER_RESOURCEGROUP_TO_RESOURCE, "", "", "", False, False, "", "", 0)
If (Err.Number &lt;&gt; 0 Or Not HasValue(objClusterResources) ) Then
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

For Each objClusterResource In objClusterResources
'Get the associated disk partition
Set objClusterDisks = objClusterResource.Associators_(WMI_CLUSTER_RESOURCE_TO_DISK_ASSOCIATOR_CLASS, "", "", "", False, False, "", "", 0)
If (Err.Number &lt;&gt; 0 Or Not HasValue(objClusterDisks) ) Then
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

For Each objClusterDisk In objClusterDisks
If (Err.Number &lt;&gt; 0) Then
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

'Get the associated resource
Set objClusterDiskPartitions = objClusterDisk.Associators_(WMI_CLUSTER_DISKPARTITION_TO_DISK_ASSOCIATOR_CLASS, "", "", "", False, False, "", "", 0)
If (Err.Number &lt;&gt; 0 Or Not HasValue(objClusterDiskPartitions) ) Then
Set objClusterDiskPartitions = Nothing
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

For Each objClusterDiskPartition In objClusterDiskPartitions
If (Err.Number &lt;&gt; 0) Then
Set objClusterDiskPartitions = Nothing
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

intSuc = CreateDiscoveryData(objClusterDisk, objClusterDiskPartition, objClusterResource, strTargetComputer, strClusterName, objDiscoveryData)

If (Err.Number &lt;&gt; 0 Or SCRIPT_WITH_ERROR = intSuc) Then
Set objClusterDiskPartitions = Nothing
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing
Exit Function
End If

Next
Next

Next

If Err.Number &lt;&gt; 0 Then
Set objClusterDiskPartitions = Nothing
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing

Exit Function
End If

Next

DiscoverClusterDisks = SCRIPT_SUCCESS
Set objClusterDiskPartitions = Nothing
Set objClusterDisks = Nothing
Set objClusterResources = Nothing
Set objResourceGroups = Nothing

On Error Goto 0
End Function

'****************************************************************************************************************
' FUNCTION: GetClusterGroup
' DESCRIPTION: Get instances of the class MSCluster_ResourceGroup using WMI.
' PARAMETERS: IN String strTargetComputer: principal name of the targeted 'Microsoft.Windows.Cluster.VirtualServer' instance.
' IN String strGroupName: the cluster group name
' OUT Object objResourceGroups: initialised ResourceGroup instance
' RETURNS: Boolean: True if successful and False if failed
'****************************************************************************************************************
Private Function GetClusterGroup(strTargetComputer, strGroupName, objMSClusterSWbemServices, ByRef objResourceGroups)

Dim objClusterResNetworks
Dim objClusterResNet
Dim objResGroupAsc
Dim objResGroups
Dim strDnsName
Dim blnUseResource
Dim strComputerName


Dim objResourceGroup

blnUseResource = False
GetClusterGroup = False
Set objResourceGroups = Nothing

On Error Resume Next

If Not HasValue(objMSClusterSWbemServices) Then
Exit Function
End If

If (0 = Len(strGroupName) ) Then
Err.Clear
strComputerName = GetComputerName(strTargetComputer)

Set objClusterResNetworks = objMSClusterSWbemServices.ExecQuery("select * from " &amp; WMI_MSCLUSTER_CLUSTER_RESOURCE &amp; " where Type = 'Network Name'")
If (Err.Number &lt;&gt; 0 Or Not HasValue(objClusterResNetworks) ) Then
Set objClusterResNetworks = Nothing
Exit Function
End If

For Each objClusterResNet In objClusterResNetworks
If Err.Number &lt;&gt; 0 Then
Set objClusterResNetworks = Nothing
Exit Function
End If
strDnsName = LCase(objClusterResNet.PrivateProperties.DnsName)

If ( strComputerName = strDnsName ) Then
blnUseResource = True
Else
blnUseResource = false
End If


If blnUseResource = true Then
Set objResGroups = objClusterResNet.Associators_(WMI_MSCLUSTER_RESOURCEGROUP_TO_RESOURCE, "", "", "", False, False, "", "", 0)
If (Err.Number &lt;&gt; 0 Or Not HasValue(objResGroups) ) Then
Set objResGroups = Nothing
Set objClusterResNetworks = Nothing
Exit Function
End If

For Each objResGroupAsc In objResGroups
If Err.Number &lt;&gt; 0 Then
Set objResGroups = Nothing
Set objClusterResNetworks = Nothing
Exit Function
End If
strGroupName = objResGroupAsc.Name
Exit For
Next

If (Len(strGroupName) &gt; 0) Then
Exit For
End If
End If
Next

If Err.Number &lt;&gt; 0 Then
Exit Function
End If

End If

If ( HasValue(strGroupName) ) Then
If Len(strGroupName) &gt; 0 Then
Set objResourceGroups = objMSClusterSWbemServices.ExecQuery("select * from " &amp; WMI_MSCLUSTER_RESOURCEGROUP &amp; " where Name='" &amp; strGroupName &amp; "'")
If Err.Number = 0 Then
GetClusterGroup = True
End If

End If
End If

Set objResGroups = Nothing
Set objClusterResNetworks = Nothing

On Error Goto 0
End Function

'****************************************************************************************************************
' FUNCTION: CreateDiscoveryData
' DESCRIPTION: Create discovery data for
' &lt;ClassType ID="Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk" Accessibility="Internal" Abstract="false" Base="Windows!Microsoft.Windows.ApplicationComponent" Hosted="true" Singleton="false"&gt;
' &lt;Property ID="ClusterResourceName" Type="string" Key="true" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;Property ID="ClusterDiskName" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;Property ID="PartitionName" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;Property ID="PartitionFileSystem" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;Property ID="PartitionSize" Type="int" Key="false" /&gt;
' &lt;Property ID="ClusterName" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;Property ID="VolumeLabel" Type="string" Key="false" CaseSensitive="false" Length="256" MinLength="0" /&gt;
' &lt;/ClassType&gt;
'
' PARAMETERS: IN Object objClusterResource: the cluster disks as SWbemObject of type MSCluster_Disk.
' IN Object objClusterDiskPartition: the associated disk partition as SWbemObject of type MSCluster_DiskPartition.
' IN Object objClusterResource: the associated cluster resource as SWbemObject of type MSCluster_Resource.
' IN String strTargetComputer: the principal name of the targeted cluster virtual server hosting the cluster shared volume,
' i.e. the cluster name and not the current owner!
' IN String strClusterName: the cluster containing the cluster shared volume
' OUT Object objDiscoveryData: initialised DiscoveryData instance
' RETURNS: Integer: 0 if successful or 1 if Error
'****************************************************************************************************************
Private Function CreateDiscoveryData(ByRef objClusterDisk, ByRef objClusterDiskPartition, ByRef objClusterResource, _
ByRef strTargetComputer, ByRef strClusterName, ByRef objDiscoveryData) 'As Integer

Dim objInstance 'As MOMClassInstance

CreateDiscoveryData = SCRIPT_WITH_ERROR
On Error Resume Next

Err.Clear
'Create the cluster shared volume instance hosted on the targeted cluster virtual server
Set objInstance = objDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.LegacyOS']$")
If Err.number &lt;&gt; 0 Then
Exit Function
End If

'PrincipalName (host, key)
Call objInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", strTargetComputer)
'ClusterSharedVolumeName (key)
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/ClusterResourceName$", objClusterResource.Properties_(WMI_NAME_PROPERTY_NAME) &amp; "_" &amp; objClusterDiskPartition.Properties_(WMI_PATH_PROPERTY_NAME))
'FriendlyVolumeName
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/ClusterDiskName$", objClusterDisk.Properties_(WMI_NAME_PROPERTY_NAME))
'PartitionName
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/PartitionName$", objClusterDiskPartition.Properties_(WMI_PATH_PROPERTY_NAME))
'PartitionFileSystem
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/PartitionFileSystem$", objClusterDiskPartition.Properties_(WMI_FILESYSTEM_PROPERTY_NAME))
'PartitionSize
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/PartitionSize$", objClusterDiskPartition.Properties_(WMI_TOTALSIZE_PROPERTY_NAME))
'ClusterName
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/ClusterName$", strClusterName)
'VolumeLabel
Call objInstance.AddProperty("$MPElement[Name='Microsoft.Windows.Server.ClusterDisksMonitoring.ClusterDisk.Base']/VolumeLabel$", objClusterDiskPartition.Properties_(WMI_VOLUMELABEL_PROPERTY_NAME))

If ( 0 = Err.Number) Then
Call objDiscoveryData.AddInstance(objInstance)
If ( 0 = Err.Number) Then
CreateDiscoveryData = SCRIPT_SUCCESS
End If

End If

Set objInstance = Nothing
On Error Goto 0
End Function

'******************************************************************************
' FUNCTION: GetScriptParameters
' DESCRIPTION: Reads the script's parameters
' and sets the global variables.
'
' PARAMETERS: OUT String strSourceID: Id of MP element ($MPElement$)
' OUT String strManagedEntityId: Id of targeted entity ($Target/Id$)
' OUT String strTargetComputer: Principal name of executing computer
' (-Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName-)
' OUT String strClusterGroupName: Cluster Group name
' RETURNS: Boolean: True if successful
'******************************************************************************
Private Function GetScriptParameters(ByRef strSourceID, ByRef strManagedEntityId, ByRef strTargetComputer, ByRef strClusterGroupName) 'As Boolean

Dim objArguments

On Error Resume Next

'cmdline: &lt;script&gt; True|False &lt;path to debug log&gt; True|False &lt;script id&gt; .MPElement. .Target/Id. .Target/Host/Property[Name="Windows!Microsoft.Windows.Computer"]/PrincipalName.
Set objArguments = WScript.Arguments
If objArguments.Count &lt; 6 Then Exit Function

Err.Clear
'Get parameters and set global variables
mblnLogSuccessEvent = CBool(objArguments(0))
If (Err.Number &lt;&gt; 0 ) Then
mblnLogSuccessEvent = False
End If

mstrIdentifier = Replace(objArguments(1), Chr(34), "")
strSourceID = Replace(objArguments(2), Chr(34), "")
strManagedEntityId = Replace(objArguments(3), Chr(34), "")
strTargetComputer = Replace(objArguments(4), Chr(34), "")
strClusterGroupName = Replace(objArguments(5), Chr(34), "")

If Len(strSourceID) &gt; 0 And Len(strManagedEntityId) &gt; 0 And Len(strTargetComputer) &gt; 0 And Len(strClusterGroupName) &gt; 0 Then GetScriptParameters = True

On Error Goto 0

End Function

'****************************************************************************************************************
' FUNCTION: GetClusterName
' DESCRIPTION: Returns the cluster name of the given cluster virtual name
' PARAMETERS: OUT String strClusterName: string to return the cluster name
' RETURNS: Boolean: True if successful
'****************************************************************************************************************
Private Function GetClusterName(ByRef strClusterName) 'As Boolean

Dim objMSClusterSWbemServices 'As SWbemServices
Dim strWQLQuery 'As String
Dim objClusters 'As SWbemObjectSet
Dim objCluster 'As SWbemObject
Dim bResult

GetClusterName = False
bResult = GetClusterNameFromRegistry(strClusterName)

If (True = bResult And Len(strClusterName) &gt; 0 ) Then
GetClusterName = bResult
Exit Function
End If

On Error Resume Next
Err.Clear

'Connect to WMI NS \\.\root\MSCluster
If ConnectToWbemNS(".", WMI_MSCLUSTER_NAMESPACE, objMSClusterSWbemServices) Then

strWQLQuery = "select * from " &amp; WMI_MSCLUSTER_CLUSTER_CLASS
Set objClusters = objMSClusterSWbemServices.ExecQuery(strWQLQuery)
If HasValue(objClusters) Then
For Each objCluster In objClusters
strClusterName = objCluster.Name
Next 'objCluster

If Len(strClusterName) &gt; 0 Then GetClusterName = True
End If
Set objClusters = Nothing

End If

On Error Goto 0

End Function


'****************************************************************************************************************
' FUNCTION: GetClusterNameFromRegistry
' DESCRIPTION: Returns the cluster name of the given cluster virtual name
' PARAMETERS: OUT String strClusterName: string to return the cluster name
' RETURNS: Boolean: True if successful
'****************************************************************************************************************
Private Function GetClusterNameFromRegistry(ByRef strClusterName) 'As Boolean

Dim objReg 'Registry
Const ClusterNamePath = "HKLM\Cluster\ClusterName"

strClusterName = ""
GetClusterNameFromRegistry = False
On Error Resume Next
Err.Clear
Set objReg = CreateObject("WScript.Shell")
strClusterName = objReg.RegRead(ClusterNamePath)

If (0 = Err.Number ) Then
GetClusterNameFromRegistry = True
End If
Set objReg = Nothing

On Error Goto 0

End Function

'****************************************************************************************************************
' FUNCTION: GetComputerName ' DESCRIPTION: return short computername
' PARAMETERS: IN String strTargetComputer: principal name of the targeted 'Microsoft.Windows.Cluster.VirtualServer' instance.
' RETURNS: Integer: 0 if successful and 1 if fails
'****************************************************************************************************************
Private Function GetComputerName(strTargetComputer)

Dim strComputerName
Dim PointPos

PointPos = InStr(strTargetComputer, ".")
If PointPos &gt; 0 Then
strComputerName = LCase(Left(strTargetComputer, PointPos - 1))
Else
strComputerName = LCase(strTargetComputer)
End If

GetComputerName = strComputerName
End Function

'******************************************************************************
' FUNCTION: ConnectToWbemNs
' DESCRIPTION: Connects to a WMI namespace
' PARAMETERS: IN String strServerName: name of the computer. If empty the local computer will be used.
' IN String strNameSpace: WMI namespace
' OUT Object objSWbemServices: WbemScripting.SWbemServices object connected to the given
' namespace on the given server
' RETURNS: Boolean: True if successful
'******************************************************************************
Private Function ConnectToWbemNS(ByRef strServerName, ByRef strNameSpace, ByRef objSWbemServices) 'As Boolean

ConnectToWbemNS = False
Dim objSWbemLocator 'as WbemScripting.SWbemLocator

On Error Resume Next
'Create a new WMI Locator object
Set objSWbemLocator = CreateObject("WbemScripting.SWbemLocator")

IF HasValue(objSWbemLocator) Then
'Connect to WMI namespace on strServerName computer and create WMI Services object
Set objSWbemServices = objSWbemLocator.ConnectServer(strServerName, strNameSpace)
END IF

'If object is initialised function will be successful
ConnectToWbemNS = HasValue(objSWbemServices)

On Error Goto 0

End Function

Private Function HasValue(Value)

Dim bNothing

bNothing = false

IF ( IsObject(Value) ) THEN
IF (Nothing is Value) THEN
bNothing = true
END IF
END IF

HasValue = Not ( IsEmpty(Value) or bNothing or IsNull(Value) )
End Function

Private Function GetLogScriptName()

GetLogScriptName = "-- Cluster Disks Discovery Script -- " &amp; vbCrLf &amp; vbCrLf &amp; "Script name: " &amp; WScript.ScriptName &amp; vbCrLf &amp; "Version: " &amp; SCRIPT_VERSION &amp; vbCrLf

End Function

'******************************************************************************
' Subroutine: LogScriptEvent
' DESCRIPTION: Logging events to EventSource
' PARAMETERS: IN Integer LogType: 0 - MomScriptApi; 1 - File, 2 - Screen .
' IN String Message: Event Description
' OUT Object objSWbemServices: WbemScripting.SWbemServices object connected to the given
' namespace on the given server
' RETURNS: Boolean: True if successful
'******************************************************************************

Sub LogScriptEvent(LogType,EventId,EventLevel,Message,objMomScriptAPI)

Dim strMessage
Dim sDate
Dim LogScriptName

On Error Resume Next
If (0 = LogType) Then
If (Not HasValue(objMomScriptAPI)) Then
Exit Sub
End If
LogScriptName = GetLogScriptName()
Call objMomScriptAPI.LogScriptEvent(LogScriptName,EventId,EventLevel,Message)

Else
sDate = Now()
strMessage = "" &amp; sDate &amp; Message

If (1 = LogType) Then
WScript.Echo strMessage
End If

End If

On Error Goto 0
End Sub
</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="VbProbe">
<Node ID="DS"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>