File Server Node Hierarchy Discovery

Microsoft.Windows.BranchCache.FileServerNodeHierarchy.Discovery (Discovery)

Discovers the BranchCache-capable File Server Group to which this computer belongs.

Knowledge Base article:

Summary

This rule discovers the BranchCache-Capable File Server Group this computer belongs to.

Element properties:

TargetMicrosoft.Windows.BranchCache.FileServerNode
EnabledTrue
Frequency14400
RemotableFalse

Object Discovery Details:

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

Member Modules:

ID Module Type TypeId RunAs 
DS DataSource Microsoft.Windows.TimedScript.DiscoveryProvider Default

Source Code:

<Discovery ID="Microsoft.Windows.BranchCache.FileServerNodeHierarchy.Discovery" Enabled="true" Target="Microsoft.Windows.BranchCache.FileServerNode" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.FileServerNode"/>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.FileServerGroup">
<Property PropertyID="SystemName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.ContentServerGroup">
<Property PropertyID="SystemName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="Microsoft.Windows.BranchCache.FileServerGroupContainsFileServerNode"/>
<DiscoveryRelationship TypeID="Microsoft.Windows.BranchCache.ContentServerGroupContainsFileServerGroup"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>BranchCache.FileServerNodeHierarchy.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Arguments>
<ScriptBody><Script>Option Explicit
SetLocale("en-us")

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 3 Then
Wscript.Quit -1
End If

Dim SourceID, ManagedEntityId, TargetComputer

SourceId = oArgs(0)
ManagedEntityId = oArgs(1)
TargetComputer = oArgs(2)

''
'' Declare some working variables and then create an empty discovery payload.
''
Dim oAPI, oDiscoveryData, cInst, mInst, dInst, relInst, relInst2

Set oAPI = CreateObject("MOM.ScriptAPI")
set oDiscoveryData = oAPI.CreateDiscoveryData(0, SourceId, ManagedEntityId)

''
'' Now, let's discover the consensus node and set its properties. When done we add it to the discovery packet
''
set cInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.BranchCache.FileServerNode']$")

call cInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call cInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", TargetComputer)
call oDiscoveryData.AddInstance(cInst)

''
'' Since we are using "contains" - we have to now discover the class instance above us. If it is
'' already discovered, Ops Manager will recognize this as a reference count increase and not a
'' separate discovery because the key property is the same.
''
set mInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.BranchCache.FileServerGroup']$")

call mInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.FileServerGroup']/SystemName$", "File Servers")
call mInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "File Servers")
call oDiscoveryData.AddInstance(mInst)

''
'' Now we have to also create an instance of the relationship to link this FileServerNode to its parent
''
set relInst = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Windows.BranchCache.FileServerGroupContainsFileServerNode']$")

relInst.Source = mInst
relInst.Target = cInst
call oDiscoveryData.AddInstance(relInst)

set dInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.BranchCache.ContentServerGroup']$")
call dInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Content Servers")
call dInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.ContentServerGroup']/SystemName$", "Content Servers")
call oDiscoveryData.AddInstance(dInst)

''
'' Now we have to also create an instance of the relationship to link this FileServerGroup to its parent
''
set relInst2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Windows.BranchCache.ContentServerGroupContainsFileServerGroup']$")

relInst2.Source = dInst
relInst2.Target = mInst
call oDiscoveryData.AddInstance(relInst2)

''
'' To force the RMS to re-assign the local agent as the managing agent for the discovered IISNode (cInst)
'' we have to get a reference to the local health service class and then create a SPECIAL SECRET relationship :)

Dim oHealthServiceInstance, oHsCnRel, oHsCnRel2

Set oHealthServiceInstance = oDiscoveryData.CreateClassInstance( "$MPElement[Name='SC!Microsoft.SystemCenter.HealthService']$" )
call oHealthServiceInstance.AddProperty ("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer )

call oDiscoveryData.AddInstance(oHealthServiceInstance)

set oHsCnRel = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oHsCnRel.Source = oHealthServiceInstance
oHsCnRel.Target = cInst

call oDiscoveryData.AddInstance(oHsCnRel)

set oHsCnRel2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='SC!Microsoft.SystemCenter.HealthServiceShouldManageEntity']$")
oHsCnRel2.Source = oHealthServiceInstance
oHsCnRel2.Target = mInst

call oDiscoveryData.AddInstance(oHsCnRel2)


''
'' And now we just return the discovery data
''
Call oAPI.Return(oDiscoveryData)</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</DataSource>
</Discovery>