Microsoft SystemCenter HealthService UpdateAgent ProbScript Action

Microsoft.SystemCenter.HealthService.UpdateAgent.ProbScript.Action (ProbeActionModuleType)

Probe action type used to trigger Microsoft SystemCenter HealthService UpdateAgent ProbScript Action.

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityPublic
RunAsSystem.PrivilegedMonitoringAccount
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
PassThrough ProbeAction System.PassThroughProbe Default
Script ProbeAction Microsoft.Windows.PowerShellPropertyBagProbe Default

Overrideable Parameters:

IDParameterTypeSelector
TargetVersionstring$Config/TargetVersion$
TimeoutSecondsint$Config/TimeoutSeconds$Timeout (sec)

Source Code:

<ProbeActionModuleType ID="Microsoft.SystemCenter.HealthService.UpdateAgent.ProbScript.Action" Accessibility="Public" Batching="false" PassThrough="false" RunAs="System!System.PrivilegedMonitoringAccount">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="TargetVersion" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="ComputerName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" maxOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AgentVersion" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TargetVersion" Selector="$Config/TargetVersion$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="PassThrough" TypeID="System!System.PassThroughProbe"/>
<ProbeAction ID="Script" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagProbe">
<ScriptName>UpdateAgentCheck.ps1</ScriptName>
<ScriptBody><Script>

Param( $TargetVersion, $AgentVersion)
$SCRIPT_NAME = "UpdateAgentCheck.ps1"
try {
$momAPI = New-Object -comObject 'MOM.ScriptAPI'
$bag = $momAPI.CreatePropertyBag()
$bag.AddValue("AgentVersion",$AgentVersion)

if (-not ([string]::IsNullOrEmpty($AgentVersion)))
{
if ([System.Version]$AgentVersion -lt [System.Version]$targetVersion)
{
$AgentCfg = New-Object -ComObject AgentConfigManager.MgmtSvcCfg
$AgentSupportsOMS = $AgentCfg | Get-Member -Name &#x2018;GetCloudWorkspaces&#x2019;
# Get all configured OMS Workspaces
$Var = $AgentCfg.GetCloudWorkspaces()
if($var -ne $null)
{
$bag.AddValue("UpdateAgentRequired", "True")
$bag.AddValue("State", "Warning")
$momAPI.LogScriptEvent($SCRIPT_NAME,1238, 0, $AgentVersion);
}
else
{
$bag.AddValue("UpdateAgentRequired", "False")
$bag.AddValue("State", "Healthy")
}
}
else
{
$bag.AddValue("UpdateAgentRequired", "False")
$bag.AddValue("State", "Healthy")
}
}
}
catch
{
$momAPI.LogScriptEvent($SCRIPT_NAME,1235, 0, $_.Exception.Message);
$bag.AddValue("UpdateAgentRequired", "False")
$bag.AddValue("State", "Healthy")
}
$bag

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>TargetVersion</Name>
<Value>$Config/TargetVersion$</Value>
</Parameter>
<Parameter>
<Name>AgentVersion</Name>
<Value>$Config/AgentVersion$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<StrictErrorHandling>true</StrictErrorHandling>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="Script">
<Node ID="PassThrough"/>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<TriggerOnly>true</TriggerOnly>
</ProbeActionModuleType>