Replicated Folder Volumes Discovery (Windows Server 2003 R2)

Microsoft.Windows.FileServer.DFSR.2003.VolumeDiscovery (Discovery)

This object discovers volumes hosting replicated folders on computers running Windows Server 2003 R2.

Knowledge Base article:

Summary

This object discovers volumes hosting replicated folders on computers running Windows Server 2003 R2. It does so by using the VolumesDiscovery2003.vbs script to query the DfsrVolumeInfo WMI class.

Configuration

Users with Author or Administrator permissions in Operations Manager can use overrides to change the following parameters:

Additional

Element properties:

TargetMicrosoft.Windows.FileServer.DFSR.2003.Service
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:
Discovered relationships and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
Microsoft.Windows.TimedScript.DiscoveryProvider DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Microsoft.Windows.FileServer.DFSR.MonitoringAccount

Source Code:

<Discovery ID="Microsoft.Windows.FileServer.DFSR.2003.VolumeDiscovery" Enabled="true" Target="Microsoft.Windows.FileServer.DFSR.2003.Service" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume">
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="IsClustered"/>
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="ClusterResourceName"/>
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="State"/>
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="DatabasePath"/>
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="VolumeGUID"/>
<Property TypeID="System!System.Entity" PropertyID="DisplayName"/>
<Property TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume" PropertyID="ClusterGroupName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="DFSRLib!Microsoft.Windows.FileServer.DFSR.Service.Contains.Volumes"/>
</DiscoveryTypes>
<DataSource ID="Microsoft.Windows.TimedScript.DiscoveryProvider" RunAs="DFSRLib!Microsoft.Windows.FileServer.DFSR.MonitoringAccount" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>VolumesDiscovery2003.vbs</ScriptName>
<Arguments>0 $MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="DFSRLib!Microsoft.Windows.FileServer.DFSR.Service"]/IsVirtualNode$</Arguments>
<ScriptBody><Script>Option Explicit

On Error Resume Next

Dim SourceType, SourceID, ManagedEntityId, oArgs, oAPI, sDfsrServerName, VolumeInfo, VolumeInfoList, volumeQuery
Dim objWMIService, oVolumeConfig, oVolumeConfigCollection, ReplicatedFolderList, validVolumeConfig

SetLocale("en-us")

Set oAPI = CreateObject("MOM.ScriptAPI")
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 3 Then
call oAPI.LogScriptEvent("VolumesDiscovery2003.vbs", 100, 1, "Expected 3 arguments. There were only " &amp; oArgs.Count &amp; " arguments. Exiting script.")
Wscript.Quit -1
End If

Dim oDiscData, oDfsrServer, stateStr, oRel, oDfsrServerRole, IsVirtualNode

SourceType = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
sDfsrServerName = oArgs(3)

if (oArgs.Count = 5) then
IsVirtualNode = oArgs(4)
else
IsVirtualNode = "False"
end if

If IsVirtualNode = "True" then
Wscript.Quit
End If

set oDiscData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)

set oDfsrServerRole = oDiscData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.2003.Service']$")

call oDfsrServerRole.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sDfsrServerName)

Call oDiscData.AddInstance(oDfsrServerRole)

Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" &amp; sDfsrServerName &amp; "\root\microsoftdfs")
if Err.Number &lt;&gt; 0 then
strErr = "Unable to connect to local DFSR WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If

volumeQuery = "Select VolumeGuid, VolumePath, DatabasePath from DfsrVolumeConfig"

Set oVolumeConfigCollection = objWMIService.ExecQuery(volumeQuery)
if Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrVolumeConfig from local DFSR WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
Wscript.Echo strErr
Wscript.Quit -1
End If

for each oVolumeConfig in oVolumeConfigCollection

stateStr = "UNINITIALIZED"
validVolumeConfig = true

set oDfsrServer = oDiscData.CreateClassInstance("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']$")

call oDfsrServer.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sDfsrServerName)
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/VolumeGUID$", oVolumeConfig.VolumeGuid)
call oDfsrServer.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", Mid(oVolumeConfig.VolumePath, 5))
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/DatabasePath$", Mid(oVolumeConfig.DatabasePath, 5))

call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/ClusterResourceName$", "N/A")
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/IsClustered$", "N/A")
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/ClusterGroupName$", "N/A")

Set VolumeInfoList = objWMIService.ExecQuery ("Select State from DfsrVolumeInfo Where VolumeGuid ='" &amp; oVolumeConfig.VolumeGuid &amp; "'")
if Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrVolumeInfo from local DFSR WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Err.Clear
oDiscData.IsSnapshot=false
Else
for each VolumeInfo in VolumeInfoList
Select Case VolumeInfo.State

Case 0
stateStr = "INITIALIZED"
Case 1
stateStr = "SHUTTING DOWN"
Case 2
stateStr = "IN ERROR"
Case 3
stateStr = "AUTO RECOVERY"
Case else
stateStr = "INVALID STATE"

End Select
Next
End If


REM
REM DFSR in some cases leaves the volume manager running and also fail to delete volume XML. when really there is no replicated
REM folders remaining and are all deleted. To handle this case, we will query DfsrReplicatedFolderConfig for folders with
REM volume GUID matching and if there are none then we will not add this volume instance, as this is just a stale object
REM

Set ReplicatedFolderList = objWMIService.ExecQuery ("Select Enabled from DfsrReplicatedFolderConfig Where VolumeGuid ='" &amp; oVolumeConfig.VolumeGuid &amp; "'")
If Err.Number &lt;&gt; 0 then
strErr = "Unable to query DfsrReplicatedFolderConfig from local DFSR WMI provider. Error: 0x" &amp; Hex(Err.Number) &amp; " " &amp; Err.Description
WScript.Echo strErr
Err.Clear
oDiscData.IsSnapshot=false
Else
If ReplicatedFolderList.Count = 0 then
validVolumeConfig = false
End If
End If


If validVolumeConfig = true then
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/State$", stateStr)

Call oDiscData.AddInstance(oDfsrServer)

Set oRel = oDiscData.CreateRelationshipInstance("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Service.Contains.Volumes']$")

oRel.Source = oDfsrServerRole
oRel.Target = oDfsrServer

Call oDiscData.AddInstance(oRel)
End If
Next

Call oAPI.Return(oDiscData)</Script></ScriptBody>
<TimeoutSeconds>900</TimeoutSeconds>
</DataSource>
</Discovery>