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.TimedPowerShell.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.TimedPowerShell.DiscoveryProvider">
<IntervalSeconds>$Config/IntervalSeconds$</IntervalSeconds>
<SyncTime/>
<ScriptName>DiscoverHealthServiceProperties.ps1</ScriptName>
<ScriptBody><Script>

param($SourceType, $SourceId, $ManagedEntityId, $ComputerIdentity, $ManagementGroupName, $IsAgent)
$oAPI = new-object -comobject "MOM.ScriptAPI"
If (($IsAgent -eq $null) -or ($IsAgent -eq "1") -or ($IsAgent -eq "") -or ($IsAgent -eq $true) -or ($IsAgent -eq "True")){
$IsAgent = $True
}Else{
$IsAgent = $False
}
$oDisc = $oAPI.CreateDiscoveryData($SourceType, $SourceId, $ManagedEntityId)
$oDisc.IsSnapshot = $True

$Version = $null
$ActionAccount = $null

try{
If ($IsAgent){
$Version = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup" | select AgentVersion -ErrorAction stop
$Version = $Version.AgentVersion
}Else{
$Version = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Microsoft Operations Manager\3.0\Setup" | select CurrentVersion -ErrorAction stop
$Version = $Version.CurrentVersion
}
}catch{
If ($Version -eq $null)
{
$oAPI.LogScriptEvent("Microsoft.SystemCenter.DiscoverHealthServiceProperties", 11, 1, "The Health Service Version registry key could not be found, error: ", $error.Description)
Exit -1;
}
}

$isNano = Get-ItemProperty "HKLM:\SOFTWARE\Microsoft\Windows NT\CurrentVersion\Server\ServerLevels"
$isNano = $isNano.NanoServer
if($isNano -ne $null)
{
$isNano = $true
}else{
$isNano = $false
}

try{
$user = ""
$domain = ""
if($isNano){
$user = $env:username
$domain = $env:userdnsdomain
}else{
$oNetwork = new-object -comobject "WScript.Network"
$user = $oNetwork.UserName
$domain = $oNetwork.UserDomain
}
If(($user.Length -eq 0) -or ($user -eq "SYSTEM")){
$ActionAccount = $user
}Else{
$ActionAccount = $domain + "\" + $user
}
}catch{
$oAPI.LogScriptEvent("Microsoft.SystemCenter.DiscoverHealthServiceProperties", 11, 1, "Failed to retrieve the User name and domain for the action account, error: ", $error.Description)
Exit -1;
}

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

$oDisc

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>SourceType</Name>
<Value>0</Value>
</Parameter>
<Parameter>
<Name>SourceId</Name>
<Value>$MPElement$</Value>
</Parameter>
<Parameter>
<Name>ManagedEntityId</Name>
<Value>$Target/Id$</Value>
</Parameter>
<Parameter>
<Name>ComputerIdentity</Name>
<Value>$Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$</Value>
</Parameter>
<Parameter>
<Name>ManagementGroupName</Name>
<Value>$Target/ManagementGroup/Name$</Value>
</Parameter>
<Parameter>
<Name>IsAgent</Name>
<Value>$Target/Property[Type="SCLibrary!Microsoft.SystemCenter.HealthService"]/IsAgent$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</DataSource>
</MemberModules>
<Composition>
<Node ID="DataSource"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Discovery.Data</OutputType>
</DataSourceModuleType>