Обнаружение филиала с размещенным кэшем, к которому относится этот компьютер, по серверу размещенного кэша, заданному в групповой политике.
Knowledge Base article:
Краткое описание
Это правило осуществляет обнаружение филиала с размещенным кэшем, к которому относится этот компьютер, по серверу размещенного кэша, заданному в групповой политике.
Function GetStdRegProvObject
Dim strComputer
strComputer = "."
Set GetStdRegProvObject = GetObject("winmgmts:\\" & strComputer & "\root\default:StdRegProv")
End Function
Function GetStringValue(strKeyPath, strValueName)
Const HKEY_LOCAL_MACHINE = &H80000002
Dim objRegistry
Set objRegistry = GetStdRegProvObject
objRegistry.GetStringValue HKEY_LOCAL_MACHINE, strKeyPath, strValueName, GetStringValue
Set objRegistry = Nothing
End Function
Function StringValueExists(strKeyPath, strValueName)
StringValueExists = Not IsNull(GetStringValue(strKeyPath, strValueName))
End Function
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count < 4 Then
WScript.Quit -1
End If
Dim SourceID, ManagedEntityId, TargetComputer, HostedCache, SingleHostedCache, GPHostedCache, GPHostedCacheExists
If CDbl(GetStringValue(strCurrentVersion, "CurrentVersion")) >= 6.2 Then
WScript.Quit -1
End If
If GPHostedCacheExists = "False" Then
If StringValueExists(strConnectionKey, "Location") Then
HostedCache = GetStringValue(strConnectionKey, "Location")
SingleHostedCache = HostedCache
End If
End If
''
'' Declare some working variables and then create an empty discovery payload.
''
Dim oAPI, oDiscoveryData, cInst, mInst, bInst, appInst, relInst, relInst2, relInst3
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.HostedCacheClientNode']$")
''
'' 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.HostedCacheClientGroup']$")
If GPHostedCacheExists = "True" Then
call mInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.HostedCacheClientGroup']/HostedCacheServerGroupName$", GPHostedCache)
call mInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "HostedCache: "+ GPHostedCache)
Else
call mInst.AddProperty("$MPElement[Name='Microsoft.Windows.BranchCache.HostedCacheClientGroup']/HostedCacheServerGroupName$", HostedCache)
call mInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "HostedCache: "+ HostedCache)
End If
call oDiscoveryData.AddInstance(mInst)
''
'' Now we have to also create an instance of the relationship to link this HostedCacheClientNode to its parent
''
set relInst = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Windows.BranchCache.HostedCacheClientGroupContainsHostedCacheClientNode']$")
relInst.Source = mInst
relInst.Target = cInst
call oDiscoveryData.AddInstance(relInst)
''
'' Now we have to also create an instance of the relationship to link this HostedCacheGroup to its parent
''
set relInst2 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Windows.BranchCache.HostedCacheGroupContainsHostedCacheClientGroup']$")
relInst2.Source = bInst
relInst2.Target = mInst
call oDiscoveryData.AddInstance(relInst2)
''
'' BranchCacheAppHostsHostedCacheGroup is using containment
'' We must also discover the BranchCacheApp and create that relationship
''
set appInst = oDiscoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Windows.BranchCache.BranchCacheApp']$")
call appInst.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "BranchCache")
call oDiscoveryData.AddInstance(appInst)
set relInst3 = oDiscoveryData.CreateRelationshipInstance("$MPElement[Name='Microsoft.Windows.BranchCache.BranchCacheAppHostsHostedCacheGroup']$")
''
'' 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 :)
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>