This object discovers volumes hosting replicated folders on computers running Windows Server 2016 and 1709+.
This object discovers volumes hosting replicated folders on computers running Windows Server 8. It does so by querying the DfsrVolumeInfo WMI class.
Users with Author or Administrator permissions in Operations Manager can use overrides to change the following parameters:
IntervalSeconds controls how often Operations Manager runs the discovery process.
Timeoutseconds controls how long to wait for discovery to complete.
DfsrVolumeInfo WMI class on MSDN (http://go.microsoft.com/fwlink/?LinkID=165543)
How to Override a Monitor (http://go.microsoft.com/fwlink/?LinkId=171027)
Target | Microsoft.Windows.FileServer.DFSR.10.0.Service |
Enabled | True |
Frequency | 14400 |
Remotable | False |
Discovered Classes and their attribuets: |
---|
|
Discovered relationships and their attribuets: |
ID | Module Type | TypeId | RunAs |
---|---|---|---|
Microsoft.Windows.TimedScript.DiscoveryProvider | DataSource | Microsoft.Windows.TimedScript.DiscoveryProvider | Microsoft.Windows.FileServer.DFSR.MonitoringAccount |
<Discovery ID="Microsoft.Windows.FileServer.DFSR.10.0.VolumeDiscovery" Enabled="true" Target="Microsoft.Windows.FileServer.DFSR.10.0.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>VolumesDiscovery63.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>
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 < 3 Then
call oAPI.LogScriptEvent("VolumesDiscovery63.vbs", 100, 1, "Expected 3 arguments. There were only " & oArgs.Count & " arguments. Exiting script.")
Wscript.Quit -1
End If
Dim oDiscData, oDfsrServer, stateStr, oRel, oDfsrServerRole, IsVirtualNode, NetworkNameClusterGroup, NetworkResourceName, IsCoreResource
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
NetworkResourceName = "N/A"
IsCoreResource = "False"
NetworkNameClusterGroup = "N/A"
Dim objClusterWMI, oResourceInfoList, oResourceInfo, oClusterGroupList, oClusterGroup
set oDiscData = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
if (isVirtualNode = "True") then
Set objClusterWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sDfsrServerName & "\root\mscluster")
if Err.Number <> 0 then
strErr = "Unable to connect to local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
Set oResourceInfoList = objClusterWMI.ExecQuery ("Select Name, CoreResource from MSCluster_Resource Where PrivateProperties.DnsName='" & Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1) & "'")
if Err.Number <> 0 then
strErr = "Unable to query MSCluster_Resource from local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
for each oResourceInfo in oResourceInfoList
NetworkResourceName = oResourceInfo.Name
IsCoreResource = oResourceInfo.CoreResource
Set oClusterGroupList = objClusterWMI.ExecQuery ("Select GroupComponent from MSCluster_ResourceGroupToResource Where PartComponent='MSCluster_Resource.Name=" & Chr(34) & oResourceInfo.Name & Chr(34) & "'")
if Err.Number <> 0 then
strErr = "Unable to query MSCluster_ResourceGroupToResource from local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
for each oClusterGroup in oClusterGroupList
NetworkNameClusterGroup = Replace(Right(oClusterGroup.GroupComponent, Len(oClusterGroup.GroupComponent) - InStr(oClusterGroup.GroupComponent, CStr(Chr(34)) )), CStr(Chr(34)), "")
Exit For
Next
Exit For
Next
Rem Check if any of the disk in this cluster group are not online. If so then the data returned by DFSR might not be complete then mark it as snapshot
Rem Get list of not online disk resources
Set oResourceInfoList = objClusterWMI.ExecQuery ("Select Name from MSCluster_Resource Where State <> 2 and ResourceClass = 1")
if Err.Number <> 0 then
strErr = "Unable to query MSCluster_Resource for not online disks from local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
for each oResourceInfo in oResourceInfoList
Dim DiskGroupName
Rem check if they belong to the same group
Set oClusterGroupList = objClusterWMI.ExecQuery ("Select GroupComponent from MSCluster_ResourceGroupToResource Where PartComponent='MSCluster_Resource.Name=" & Chr(34) & oResourceInfo.Name & Chr(34) & "'")
if Err.Number <> 0 then
strErr = "Unable to query disk group name against MSCluster_ResourceGroupToResource from local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
for each oClusterGroup in oClusterGroupList
DiskGroupName = Replace(Right(oClusterGroup.GroupComponent, Len(oClusterGroup.GroupComponent) - InStr(oClusterGroup.GroupComponent, CStr(Chr(34)) )), CStr(Chr(34)), "")
Exit For
Next
if DiskGroupName = NetworkNameClusterGroup then
Rem we found a not online disk in the group
oDiscData.IsSnapshot=false
Exit For
End if
Next
end if
set oDfsrServerRole = oDiscData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.FileServer.DFSR.10.0.Service']$")
call oDfsrServerRole.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", sDfsrServerName)
Call oDiscData.AddInstance(oDfsrServerRole)
if IsCoreResource = "False" then
Set objWMIService = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sDfsrServerName & "\root\microsoftdfs")
if Err.Number <> 0 then
strErr = "Unable to connect to local DFSR WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Wscript.Quit -1
End If
volumeQuery = "Select VolumeGuid, VolumePath, IsClustered, ClusterDiskResName, DatabasePath from DfsrVolumeConfig where IsClustered = " & IsVirtualNode
Set oVolumeConfigCollection = objWMIService.ExecQuery(volumeQuery)
if Err.Number <> 0 then
strErr = "Unable to query DfsrVolumeConfig from local DFSR WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
Wscript.Echo strErr
Wscript.Quit -1
End If
for each oVolumeConfig in oVolumeConfigCollection
Dim diskClusterGroupName
diskClusterGroupName = "N/A"
stateStr = "UNINITIALIZED"
validVolumeConfig = true
if (IsVirtualNode = "True") then
REM Make sure that the disk resource belong to same group as the Network Name group
Set objClusterWMI = GetObject("winmgmts:{impersonationLevel=impersonate}!\\" & sDfsrServerName & "\root\mscluster")
if Err.Number <> 0 then
strErr = "Unable to connect to local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
WScript.Echo strErr
Rem Wscript.Quit -1
oDiscData.IsSnapshot=false
Else
Set oClusterGroupList = objClusterWMI.ExecQuery ("Select GroupComponent from MSCluster_ResourceGroupToResource Where PartComponent='MSCluster_Resource.Name=" & Chr(34) & oVolumeConfig.ClusterDiskResName & Chr(34) & "'")
if Err.Number <> 0 then
strErr = "Unable to query MSCluster_ResourceGroupToResource from local mscluster WMI provider. Error: 0x" & Hex(Err.Number) & " " & Err.Description
Wscript.Echo strErr
Rem Wscript.Quit -1
oDiscData.IsSnapshot=false
Else
for each oClusterGroup in oClusterGroupList
diskClusterGroupName = Replace(Right(oClusterGroup.GroupComponent, Len(oClusterGroup.GroupComponent) - InStr(oClusterGroup.GroupComponent, CStr(Chr(34)) )), CStr(Chr(34)), "")
Exit For
Next
End If
End if
end if
if (diskClusterGroupName = NetworkNameClusterGroup) then
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']/IsClustered$", oVolumeConfig.IsClustered)
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/ClusterGroupName$", diskClusterGroupName)
if (CStr(oVolumeConfig.IsClustered) = "True") then
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/ClusterResourceName$", oVolumeConfig.ClusterDiskResName)
else
call oDfsrServer.AddProperty("$MPElement[Name='DFSRLib!Microsoft.Windows.FileServer.DFSR.Volume']/ClusterResourceName$", "N/A")
end if
Set VolumeInfoList = objWMIService.ExecQuery ("Select State from DfsrVolumeInfo Where VolumeGuid ='" & oVolumeConfig.VolumeGuid & "'")
if Err.Number <> 0 then
strErr = "Unable to query DfsrVolumeInfo from local DFSR WMI provider. Error: 0x" & Hex(Err.Number) & " " & 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 ContainerComputerName ='" & Left(sDfsrServerName, InStr(sDfsrServerName, ".")-1) & "' and VolumeGuid ='" & oVolumeConfig.VolumeGuid & "'")
If Err.Number <> 0 then
strErr = "Unable to query DfsrReplicatedFolderConfig from local DFSR WMI provider. Error: 0x" & Hex(Err.Number) & " " & 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
End If
Next
End If
Call oAPI.Return(oDiscData)
</ScriptBody>
<TimeoutSeconds>900</TimeoutSeconds>
</DataSource>
</Discovery>