' This Script is used to check if the specified file's version is greater than or equal to expectedversion
' If the actual version is greater than expected one, then output Healthy
' Otherwise output UnHealthy
Dim oArgs, oBag, oAPI, objFSO, actualVersion, fileName, parentPath, expectedValue
Set oAPI = CreateObject("MOM.ScriptAPI")
' There are 3 arguments, they are the following values.
' (1) FileName
' (2) ParentPath
' (3) ExpectedVersion
Set oArgs = Wscript.Arguments
' Check to see if the required script arguments are there
' 3 argument are requried
' If 3 argument do not exist, log a script event
If oArgs.Count = 3 Then
Set oBag = oAPI.CreatePropertyBag()
' Check if the ParentPath is present
if objFSO.FolderExists(parentPath) Then
Call oBag.AddValue("parentPath Exists", "Yes")
' Check if the speicified file is present
if objFSO.FileExists(parentPath& "\" &fileName) Then
Call oBag.AddValue("Expected File Exists", "Yes")
' Get the version of the specified file
actualVersion = objFSO.GetFileVersion(parentPath& "\" &fileName)
if actualVersion < expectedValue Then
Call oBag.AddValue("Update Installed", "UnHealthy")
else
Call oBag.AddValue("Update Installed", "Healthy")
End if
Call oBag.AddValue("ActualVersion", actualVersion)
Call oBag.AddValue("ExpectedVersion", expectedValue)
Else
Call oBag.AddValue("Expected File Exists", "No")
Call oBag.AddValue("Update Installed", "UnHealthy")
End If
Else
' If the parentpath is absent, output UnHealthy
Call oBag.AddValue("parentPath Exists", "No")
Call oBag.AddValue("Update Installed", "UnHealthy")
End If
Call oAPI.Return(oBag)
Else
Call oAPI.LogScriptEvent("HyperVHostUpdateMonitor.vbs", 101, 0, "HyperVHostUpdateMonitor was not called with 3 argument and was not executed.")
End If </Script></ScriptBody>
<SecureInput/>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
<EventPolicy/>
</DataSource>
<ConditionDetection ID="ErrorFilter" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Update Installed']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">UnHealthy</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
<ConditionDetection ID="SuccessFilter" TypeID="System!System.ExpressionFilter">
<Expression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Update Installed']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">Healthy</Value>
</ValueExpression>
</SimpleExpression>
</Expression>
</ConditionDetection>
</MemberModules>
<RegularDetections>
<RegularDetection MonitorTypeStateID="Error">
<Node ID="ErrorFilter">
<Node ID="DataSource"/>
</Node>
</RegularDetection>
<RegularDetection MonitorTypeStateID="Success">
<Node ID="SuccessFilter">
<Node ID="DataSource"/>
</Node>
</RegularDetection>
</RegularDetections>
</MonitorImplementation>
</UnitMonitorType>