Distributed Cache Client Node Hierarchy Discovery

Microsoft.Windows.BranchCache.DistributedCacheClientNodeHierarchy.Discovery (Discovery)

Discovers the Distributed Cache Client Group to which this computer belongs based on its Active Directory (AD) Site attribute.

Knowledge Base article:

Summary

This rule discovers the Distributed Cache Client Group this computer belongs to based on its AD Site attribute.

Element properties:

TargetMicrosoft.Windows.BranchCache.DistributedCacheClientNode
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.DistributedCacheClientNodeHierarchy.Discovery" Enabled="true" Target="Microsoft.Windows.BranchCache.DistributedCacheClientNode" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.DistributedCacheClientNode">
<Property TypeID="Microsoft.Windows.BranchCache.ClientSideServiceBase" PropertyID="NodeName"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.DistributedCacheGroup">
<Property PropertyID="ADSite"/>
</DiscoveryClass>
<DiscoveryClass TypeID="Microsoft.Windows.BranchCache.BranchOfficeGroup">
<Property PropertyID="SystemName"/>
</DiscoveryClass>
<DiscoveryRelationship TypeID="Microsoft.Windows.BranchCache.DistributedCacheGroupContainsDistributedCacheClientNode"/>
<DiscoveryRelationship TypeID="Microsoft.Windows.BranchCache.BranchOfficeGroupContainsDistributedCacheGroup"/>
</DiscoveryTypes>
<DataSource ID="DS" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>14400</IntervalSeconds>
<SyncTime/>
<ScriptName>BranchCache.DistributedCacheClientNodeHierarchy.Discovery.vbs</ScriptName>
<Arguments>$MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/ActiveDirectorySite$</Arguments>
<ScriptBody><Script>Option Explicit
SetLocale("en-us")

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

Dim SourceID, ManagedEntityId, TargetComputer, ActiveDirectorySite

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

''
'' Declare some working variables and then create an empty discovery payload.
''
Dim oAPI, oDiscoveryData, cInst, mInst, bInst, 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.DistributedCacheClientNode']$")

call cInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer)
call cInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.ClientSideServiceBase']/NodeName$", 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.DistributedCacheGroup']$")

call mInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.DistributedCacheGroup']/ADSite$", ActiveDirectorySite)
call mInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "DistributedCache: " + ActiveDirectorySite)
call oDiscoveryData.AddInstance(mInst)

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

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

set bInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.BranchCache.BranchOfficeGroup']$")
call bInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Branch Offices")
call bInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.BranchOfficeGroup']/SystemName$", "Branch Offices")
call oDiscoveryData.AddInstance(bInst)

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

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

''
'' To force the RMS to re-assign the local agent as the managing agent for the discovered HostedCacheClientNode (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>