Health Service Property Discovery Data Source

Microsoft.SystemCenter.HealthServicePropertyDiscovery (DataSourceModuleType)

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
OutputTypeSystem.Discovery.Data
CommentGets information out of Registry for HealthService properties. Can't use the Registry Provider since we can't cast REG_DWORD's to bool types (e.g. 1 == true), so we do it in this DS

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
IntervalSecondsint$Config/IntervalSeconds$Interval Seconds
TimeoutSecondsint$Config/TimeoutSeconds$Timeout Seconds

Source Code:

<DataSourceModuleType ID="Microsoft.SystemCenter.HealthServicePropertyDiscovery" Comment="Gets information out of Registry for HealthService properties. Can't use the Registry Provider since we can't cast REG_DWORD's to bool types (e.g. 1 == true), so we do it in this DS " Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element name="IntervalSeconds" type="xsd:integer"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="DataSource" TypeID="Windows!Microsoft.Windows.TimedScript.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverHealthServiceProperties.vbs</ScriptName>
<Arguments>0 $MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ "$Target/ManagementGroup/Name$" $Target/Property[Type="SCLibrary!Microsoft.SystemCenter.HealthService"]/IsAgent$</Arguments>
<ScriptBody><Script>

Option Explicit
Dim oAPI
Set oAPI = CreateObject("MOM.ScriptAPI")

Dim oArgs
Set oArgs = WScript.Arguments
if oArgs.Count &lt; 5 Then
call oAPI.LogScriptEvent("Microsoft.SystemCenter.DiscoverHealthServiceProperties", 12, 1, "Expected 5 arguments. There were only " &amp; oArgs.Count &amp; " arguments. Exiting script.")
Wscript.Quit -1
End If

Dim SourceType
Dim SourceId
Dim ManagedEntityId
Dim ComputerIdentity
Dim ManagementGroup
Dim IsAgent

SourceType = oArgs(0)
SourceId = oArgs(1)
ManagedEntityId = oArgs(2)
ComputerIdentity = oArgs(3)
ManagementGroup = oArgs(4)
If IsNull(oArgs(5)) = "True" Or oArgs(5) = "1" Then
IsAgent = True
Else
IsAgent = False
End If

Dim oDisc
set oDisc = oAPI.CreateDiscoveryData(SourceType, SourceId, ManagedEntityId)
oDisc.IsSnapshot = True

dim oRegistry
dim Version
dim ActionAccount

set oRegistry = CreateObject("WScript.Shell")

On Error Resume Next
If IsAgent = True Then
Version = oRegistry.RegRead("HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\AgentVersion")
Else
Version = oRegistry.RegRead("HKLM\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup\CurrentVersion")
End If

If (Err.Number &lt;&gt; 0) Then
call oAPI.LogScriptEvent("Microsoft.SystemCenter.DiscoverHealthServiceProperties", 11, 1, "The Health Service Version registry key could not be found, error: " &amp; Err.Description)
Wscript.Quit -1
End If

Dim oNetwork
set oNetwork = CreateObject("WScript.Network")
If (Len(oNetwork.UserDomain) = 0 or oNetwork.UserName = "SYSTEM") Then
ActionAccount = oNetwork.UserName
Else
ActionAccount = oNetwork.UserDomain &amp; "\" &amp; oNetwork.UserName
End If
If (Err.Number &lt;&gt; 0) Then
call oAPI.LogScriptEvent("Microsoft.SystemCenter.DiscoverHealthServiceProperties", 11, 1, "Failed to retrieve the User name and domain for the action account, error: " &amp; Err.Description)
Wscript.Quit -1
End If

On Error GoTo 0

Dim oInst
set oInst = oDisc.CreateClassInstance("$MPElement[Name='SCLibrary!Microsoft.SystemCenter.HealthService']$")
call oInst.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", ComputerIdentity)
call oInst.AddProperty("$MPElement[Name='SCLibrary!Microsoft.SystemCenter.HealthService']/Version$", Version)
call oInst.AddProperty("$MPElement[Name='SCLibrary!Microsoft.SystemCenter.HealthService']/ActionAccountIdentity$", ActionAccount)
call oDisc.AddInstance(oInst)

call oAPI.Return(oDisc)

</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DataSource"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>