Microsoft.Office.XP.Outlook.PassiveCommunicationStatus.ModuleType (ProbeActionModuleType)

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.Event.Data
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
DS ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default

Overrideable Parameters:

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

Source Code:

<ProbeActionModuleType ID="Microsoft.Office.XP.Outlook.PassiveCommunicationStatus.ModuleType" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element name="Computer" type="xsd:string"/>
<xsd:element name="IntervalSeconds" type="xsd:int"/>
<xsd:element name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="IntervalSeconds" Selector="$Config/IntervalSeconds$" ParameterType="int"/>
<OverrideableParameter ID="TimeoutSeconds" ParameterType="int" Selector="$Config/TimeoutSeconds$"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="DS" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>Outlook2003Status.vbs</ScriptName>
<Arguments>$Config/Computer$ $Config/IntervalSeconds$</Arguments>
<ScriptBody><Script>

'Copyright (c) Microsoft Corporation. All rights reserved.
' We check outlook connectivity

' Event Constants
Const EVENT_TYPE_SUCCESS = 0
Const EVENT_TYPE_ERROR = 1
Const EVENT_TYPE_WARNING = 2
Const EVENT_TYPE_INFORMATION = 4

' Error Constants
Const ERROR_SYSTEM_DRIVE = 7701
Const ERROR_GENERAL_WARNING = 7700
Const ERROR_GENERAL_ERROR = 7702
Const ERROR_CREATION_ERROR = 7703

' WMI Constants
Const wbemCimtypeUseDefault = 0 'Use Default Type CIM type - Custom
Const wbemCimtypeSint16 = 2 'Signed 16-bit integer
Const wbemCimtypeSint32 = 3 'Signed 32-bit integer
Const wbemCimtypeReal32 = 4 '32-bit real number
Const wbemCimtypeReal64 = 5 '64-bit real number
Const wbemCimtypeString = 8 'String
Const wbemCimtypeBoolean = 11 'Boolean value
Const wbemCimtypeObject = 13 'CIM object
Const wbemCimtypeSint8 = 16 'Signed 8-bit integer
Const wbemCimtypeUint8 = 17 'Unsigned 8-bit integer
Const wbemCimtypeUint16 = 18 'Unsigned 16-bit integer
Const wbemCimtypeUint32 = 19 'Unsigned 32-bit integer
Const wbemCimtypeSint64 = 20 'Signed 64-bit integer
Const wbemCimtypeUint64 = 21 'Unsigned 64-bit integer
Const wbemCimtypeDatetime = 101 'Date/time value
Const wbemCimtypeReference = 102 'Reference to a CIM object
Const wbemCimtypeChar16 = 103 '16-bit character

Const ErrAction_None = 0
Const ErrAction_Trace = 1
Const ErrAction_ThrowError = 16
Const ErrAction_Abort = 32
Const ErrAction_ThrowErrorAndAbort = 48


Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count &lt; 2 Then
' Less than what we expected
' We cann't create a event here but may be what?
Wscript.Quit -1
End If

Dim TargetComputer, IntervalSecondsConfig

TargetComputer = oArgs(0)
IntervalSecondsConfig = oArgs(1)


Dim oAPI, oBag

'******************************************************************************
'
' Purpose: To generate a MOM event
'
' Arguments: lEventID, the event code
' lEventType, the severity of the event
' strMessage, the message to include in the event
'
'******************************************************************************
Sub CreateEvent(lEventID, lEventType, strMessage)
On Error Resume Next
Call oAPI.LogScriptEvent("[Outlook Passive Script ]",lEventID ,lEventType,strMessage)
' Clear the event here
err.Clear
End Sub

'******************************************************************************
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'******************************************************************************
Function ThrowScriptErrorNoAbort(ByVal sMessage, ByVal oErr)
Dim sErrDescription, sErrNumber
sErrDescription = oErr.Description
sErrNumber = oErr.Number
Dim warningMessage
warningMessage = VbCrLf &amp; "Message:- " &amp; sMessage &amp; "."
If (Not IsNull(sErrDescription)) And (Not IsEmpty(sErrDescription)) And sErrNumber &lt;&gt; 0 Then
warningMessage = warningMessage &amp; VbCrLf &amp; " Message Description:- " &amp; sErrDescription &amp; "." &amp; VbCrLf &amp;" Error number which caused this problem is :- " &amp; sErrNumber &amp; ". "
End If
'CreateEvent ERROR_GENERAL_WARNING ,EVENT_TYPE_WARNING, warningMessage &amp; VbCrLf &amp; "Action:- bailing out of probe action"
End Function

'******************************************************************************
'
' ThrowScriptError :: Creates an event and sends it back to the mom server
'
'******************************************************************************
Function ThrowScriptError(Byval sMessage, ByVal oErr)
On Error Resume Next
Dim sErrDescription, sErrNumber
sErrDescription = oErr.Description
sErrNumber = oErr.Number
Dim warningMessage
warningMessage = VbCrLf &amp; "Message:- " &amp; sMessage &amp; "."
If (Not IsNull(sErrDescription)) And (Not IsEmpty(sErrDescription)) And sErrNumber &lt;&gt; 0 Then
warningMessage = warningMessage &amp; VbCrLf &amp; " Error Message Description:- " &amp; sErrDescription &amp; "." &amp; VbCrLf &amp;" Error number which caused this problem is :- " &amp; sErrNumber &amp; ". "
End If
'CreateEvent ERROR_GENERAL_ERROR,EVENT_TYPE_ERROR, warningMessage &amp; VbCrLf &amp; "Action:- bailing out of probe action"
Wscript.Quit -1
End Function

' Clear error
err.clear
' Create MOM Script API
Set oAPI = CreateObject("MOM.ScriptAPI")

If IsEmpty(oAPI) Or IsNull(oAPI) Or err.number &lt;&gt; 0 Then
' Unable to create MOM Script API
' CreateEvent ERROR_GENERAL_ERROR,EVENT_TYPE_ERROR, "Unable to create MOM Script API" &amp; VbCrLf &amp; "Action:- bailing out of probe action"
Wscript.Quit -1
End If

Set oBag = oAPI.CreatePropertyBag()

If IsNull(oBag) Or IsEmpty(oBag) Or err.number &lt;&gt; 0 Then
' Unable to create property bag
CreateEvent ERROR_GENERAL_ERROR,EVENT_TYPE_ERROR, "Unable to create Property Bag" &amp; VbCrLf &amp; "Action:- bailing out of probe action"
Wscript.Quit -1
End If

If CheckStatus(TargetComputer) &gt;= 0 Then
Call oAPI.Return(oBag)
Else
Wscript.Quit -1
End If


'******************************************************************************
'
' CheckStatus :: Check AD connectivity
'
'******************************************************************************

Function CheckStatus(ByVal sTargetComputer)

' Frist check if the computer cann't reach the domain controller
Dim connectionToDomainController
Dim strDomain, objRootDSE

' Get Domain name from RootDSE object.

connectionToDomainController=true

On Error Resume Next

Set objRootDSE = GetObject("LDAP://RootDSE")

' Try once more as some times, we might not get this object for first call itself
If IsNull(objRootDSE) Or err.number &lt;&gt; 0 Then
On Error Resume Next
Set objRootDSE = GetObject("LDAP://RootDSE")
End If

On Error Goto 0

If IsNull(objRootDSE) Or err.number &lt;&gt; 0 Then
connectionToDomainController=false
Else
strDomain = objRootDSE.Get("DefaultNamingContext")
If IsNull(strDomain) Or IsEmpty(strDomain) Or err.number &lt;&gt; 0 Then
' We are unable to fetch default naming context so it may be because we are unable to get the data due to network disconnection(uncertian)
connectionToDomainController=false
End If
End If

If connectionToDomainController = false Then
oBag.AddValue "Status","Green"
Else
oBag.AddValue "Status","Red"
End If

CheckStatus = 0

End Function


Function WMIGetObject(ByVal sNamespace)
'
' WMIGetObject :: Returns the WMI object requested.
'
'
Dim oWMI
Dim e
Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" &amp; sNamespace &amp; "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists.", e
End If

Set WMIGetObject = oWMI

End Function



Function WMIGetInstance(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstance :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount
Dim e
Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" &amp; sNamespace &amp; "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists.", e
End If

On Error Resume Next
Set oInstance = oWMI.InstancesOf(sInstance)
e.Save
On Error Goto 0
If IsEmpty(oInstance) Or e.Number &lt;&gt; 0 Then
ThrowScriptError "The class name '" &amp; sInstance &amp; "' returned no instances. Please check to see if this is a valid WMI class name.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty

On Error Resume Next
nInstanceCount = oInstance.Count
e.Save
On Error Goto 0
If e.Number &lt;&gt; 0 Then
ThrowScriptError "The class name '" &amp; sInstance &amp; "' did not return any valid instances. Please check to see if this is a valid WMI class name.", e
End If

Set WMIGetInstance = oInstance

End Function

Function WMIExecQuery(ByVal sNamespace, ByVal sQuery)
'
' WMIExecQuery :: Executes the WMI query and returns the result set.
'
'
Dim oWMI, oQuery, nInstanceCount
Dim e
Set e = New Error
On Error Resume Next
Set oWMI = GetObject(sNamespace)
e.Save
On Error Goto 0
If IsEmpty(oWMI) Then
ThrowScriptError "Unable to open WMI Namespace '" &amp; sNamespace &amp; "'. Check to see if the WMI service is enabled and running, and ensure this WMI namespace exists.", e
End If

On Error Resume Next
Set oQuery = oWMI.ExecQuery(sQuery)
e.Save
On Error Goto 0
If IsEmpty(oQuery) Or e.Number &lt;&gt; 0 Then
ThrowScriptError "The Query '" &amp; sQuery &amp; "' returned an invalid result set. Please check to see if this is a valid WMI Query.", e
End If

'Determine if we queried a valid WMI class - Count will return 0 or empty
On Error Resume Next
nInstanceCount = oQuery.Count
e.Save
On Error Goto 0
If e.Number &lt;&gt; 0 Then
ThrowScriptError "The Query '" &amp; sQuery &amp; "' did not return any valid instances. Please check to see if this is a valid WMI Query.", e
End If

Set WMIExecQuery = oQuery

End Function

Function WMIGetInstanceNoAbort(ByVal sNamespace, ByVal sInstance)
'
' WMIGetInstanceNoAbort :: Returns WMI Instance requested.
'
'
Dim oWMI, oInstance, nInstanceCount

On Error Resume Next
Set oWMI = GetObject(sNamespace)
If Not IsEmpty(oWMI) Then

Set oInstance = oWMI.InstancesOf(sInstance)
If Not IsEmpty(oInstance) And Err.Number = 0 Then

'Determine if we queried a valid WMI class - Count will return 0 or empty
nInstanceCount = oInstance.Count
If Err.Number = 0 Then
Set WMIGetInstanceNoAbort = oInstance
Exit Function
End If
End If
End If
On Error Goto 0

Set WMIGetInstanceNoAbort = Nothing

End Function

Function GetWMIProperty(oWmi, sPropName, nCIMType, ErrAction)
Dim sValue, oWmiProp

If Not IsValidObject(oWmi) Then
If (ErrAction And ErrAction_ThrowError) = ErrAction_ThrowError Then _
ThrowScriptErrorNoAbort "Accessing property on invalid WMI object.", Err

If (ErrAction And ErrAction_Abort) = ErrAction_Abort Then _
Quit()

GetWMIProperty = ""
Exit Function
End If

On Error Resume Next
Set oWmiProp = oWmi.Properties_.Item(sPropName)
If Err.Number &lt;&gt; 0 Then
If (ErrAction And ErrAction_ThrowError) = ErrAction_ThrowError Then _
ThrowScriptErrorNoAbort "An error occurred while accessing WMI property: '" &amp; sPropName &amp; "'.", Err

If (ErrAction And ErrAction_Abort) = ErrAction_Abort Then _
Quit()
End If
On Error Goto 0

If IsValidObject(oWmiProp) Then
sValue = oWmiProp.Value

If IsNull(sValue) Then
'
' If value is null, return blank to avoid any issues
'
GetWMIProperty = ""

Else

Select Case (oWmiProp.CIMType)
Case wbemCimtypeString, wbemCimtypeSint16, wbemCimtypeSint32, wbemCimtypeReal32, wbemCimtypeReal64, wbemCimtypeSint8, wbemCimtypeUint8, wbemCimtypeUint16, wbemCimtypeUint32, wbemCimtypeSint64, wbemCimtypeUint64:
If Not oWmiProp.IsArray Then
GetWMIProperty = Trim(CStr(sValue))
Else
GetWMIProperty = Join(sValue, ", ")
End If
Case wbemCimtypeBoolean:
If sValue = 1 Or UCase(sValue) = "TRUE" Then
GetWMIProperty = "True"
Else
GetWMIProperty = "False"
End If
Case wbemCimtypeDatetime:

Dim sTmpStrDate

'
' First attempt to convert the whole wmi date string
'
sTmpStrDate = Mid(sValue, 5, 2) &amp; "/" &amp; _
Mid(sValue, 7, 2) &amp; "/" &amp; _
Left(sValue, 4) &amp; " " &amp; _
Mid (sValue, 9, 2) &amp; ":" &amp; _
Mid(sValue, 11, 2) &amp; ":" &amp; _
Mid(sValue, 13, 2)
If IsDate(sTmpStrDate) Then
GetWMIProperty = CDate(sTmpStrDate)
Else

'
' Second, attempt just to convert the YYYYMMDD
'
sTmpStrDate = Mid(sValue, 5, 2) &amp; "/" &amp; _
Mid(sValue, 7, 2) &amp; "/" &amp; _
Left(sValue, 4)
If IsDate(sTmpStrDate) Then
GetWMIProperty = CDate(sTmpStrDate)
Else
'
' Nothing works - return passed in string
'
GetWMIProperty = sValue
End If

End If

Case Else:
GetWMIProperty = ""
End Select
End If
Else

If (ErrAction And ErrAction_ThrowError) = ErrAction_ThrowError Then _
ThrowScriptErrorNoAbort "An error occurred while accessing WMI property: '" &amp; sPropName &amp; "'.", Err

If (ErrAction And ErrAction_Abort) = ErrAction_Abort Then _
Quit()

GetWMIProperty = ""

End If


If (ErrAction And ErrAction_Trace) = ErrAction_Trace Then _
WScript.Echo " + " &amp; sPropName &amp; " :: '" &amp; GetWMIProperty &amp; "'"

End Function


Class Error
Private m_lNumber
Private m_sSource
Private m_sDescription
Private m_sHelpContext
Private m_sHelpFile
Public Sub Save()
m_lNumber = Err.number
m_sSource = Err.Source
m_sDescription = Err.Description
m_sHelpContext = Err.HelpContext
m_sHelpFile = Err.helpfile
End Sub
Public Sub Raise()
Err.Raise m_lNumber, m_sSource, m_sDescription, m_sHelpFile, m_sHelpContext
End Sub
Public Sub Clear()
m_lNumber = 0
m_sSource = ""
m_sDescription = ""
m_sHelpContext = ""
m_sHelpFile = ""
End Sub
Public Default Property Get Number()
Number = m_lNumber
End Property
Public Property Get Source()
Source = m_sSource
End Property
Public Property Get Description()
Description = m_sDescription
End Property
Public Property Get HelpContext()
HelpContext = m_sHelpContext
End Property
Public Property Get HelpFile()
HelpFile = m_sHelpFile
End Property
End Class

Function MomCreateObject(ByVal sProgramId)
Dim oError
Set oError = New Error

On Error Resume Next
Set MomCreateObject = CreateObject(sProgramId)
oError.Save
On Error Goto 0

If oError.Number &lt;&gt; 0 Then ThrowScriptError "Unable to create automation object '" &amp; sProgramId &amp; "'", oError
End Function

Function IsValidObject(ByVal oObject)
IsValidObject = False

If IsObject(oObject) Then
If Not oObject Is Nothing Then
IsValidObject = True
End If
End If
End Function

Function Quit()

WScript.Quit()

End Function

</Script></ScriptBody>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="DS"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.Event.Data</InputType>
</ProbeActionModuleType>