Forefront SP Log Realtime Scan Num

Forefront_SP_Log_Realtime_Scan_Num (WriteActionModuleType)

Log the number of enabled FSSP Realtime Scanner to MOM Log file.

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
Comment{272A54F7-02AD-435C-8A66-976656C356A7}

Member Modules:

ID Module Type TypeId RunAs 
RunScriptAction WriteAction System.Mom.BackwardCompatibility.ScriptResponse Default

Overrideable Parameters:

IDParameterTypeSelectorDisplay NameDescription
Callerstring$Config/Parameters/Caller$Caller
TextLogstring$Config/Parameters/TextLog$TextLog

Source Code:

<WriteActionModuleType ID="Forefront_SP_Log_Realtime_Scan_Num" Accessibility="Internal" Comment="{272A54F7-02AD-435C-8A66-976656C356A7}">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>MomBackwardCompatibility!System.Mom.BackwardCompatibility.AlertGenerationSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="AlertGeneration" type="AlertGenerationType"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="InvokerType" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="Parameters" minOccurs="0">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="Caller" type="xsd:string" minOccurs="0"/>
<xsd:element name="TextLog" type="xsd:string" minOccurs="0"/>
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="Caller" Selector="$Config/Parameters/Caller$" ParameterType="string"/>
<OverrideableParameter ID="TextLog" Selector="$Config/Parameters/TextLog$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation>
<Composite>
<MemberModules>
<WriteAction ID="RunScriptAction" TypeID="MomBackwardCompatibility!System.Mom.BackwardCompatibility.ScriptResponse">
<AlertGeneration>$Config/AlertGeneration$</AlertGeneration>
<InvokerType>$Config/InvokerType$</InvokerType>
<Body><Script>

'*******************************************************************************************
'*
'* Function:
'* ---------
'* $File$
'* $Revision$
'*
'* Purpose:
'* --------
'* Check number of Realtime Scanner enabled and log the number to MOM Logs
'*
'*
'*******************************************************************************************

' Constant for controlling text file operations

Const FOR_READING = 1

'Registry Constants

Const HIVE = "HKEY_LOCAL_MACHINE\"
Const REG_KEY = "SOFTWARE\Microsoft\Forefront Server Security\"




Public ForefrontInstallPath



ForefrontInstallPath = RetrieveRegValue (REG_KEY &amp; "SharePoint","InstalledPath", 1)
InstalledProduct = "SharePoint"

Caller = ScriptContext.Parameters.Get("Caller")
TextLogParameter = ScriptContext.Parameters.Get("TextLog")

If IsNull(ForefrontInstallPath) Then
WriteMOMEvent "TASK ERROR: Unable To Retrieve Forefront for SharePoint Installation Path", 1, INSTALL_PATH_FAIL
ScriptContext.Quit
End If

If TextLogParameter = "true" then
CreateLogFolder(ForefrontInstallPath)
End If

WriteLog "NULL"
WriteLog "Beginning Check the number of FSSP Realtime Scanner and log to MOM Logs Called by " &amp; Caller



RealtimeEnableNum=0

RealtimeEnableNum = State.get("FSSP_RealtimeEnableNum")

WriteLog "RealtimeEnableNum=" &amp; RealtimeEnableNum


WriteLog "Finished Execution of Forefront SP Log Realtime Scan Num Script"







'***********************************************************************
'*
'* Function: CreateLogFolder()
'*
'* Purpose: Creates Log subfolder under Forefront
'*
'***********************************************************************

Function CreateLogFolder (ForefrontInstallPath)

Dim objFSO
set objFSO = CreateObject ("Scripting.FileSystemObject")

If objFSO.FolderExists(ForefrontInstallPath &amp; "\MOMLogs") = 0 then
objFSO.CreateFolder(ForefrontInstallPath &amp; "\MOMLogs")
End If

Set objFSO = Nothing

End Function


'***********************************************************************
'*
'* Function: WriteLog()
'*
'* Purpose: Writes script activity and errors to a log file
'*
'***********************************************************************


Function WriteLog (strLogText)

Dim objfs
Dim objf
Dim strTimeStamp

If TextLogParameter = "true" Then

On Error Resume Next
Err.Clear

Set objfs = CreateObject("Scripting.FileSystemObject")
Set objf = objfs.OpentextFile(ForefrontInstallPath &amp; "\MOMLogs\" &amp; "Tasks.log", 8, False)


' If log file doesn't exist - create it
If Err.Number &lt;&gt; 0 Then
Set objf = objfs.CreatetextFile(ForefrontInstallPath &amp; "\MOMLogs\" &amp; "Tasks.log", False)
Err.Clear
End If

If strLogText = "NULL" then
objf.WriteLine("")
Else
strTimeStamp = Date &amp; " " &amp; Time &amp; " "
objf.WriteLine(strTimeStamp &amp; strLogText)
End If
End If

Set objfs = Nothing
Set objf = Nothing

End Function




'***********************************************************************
'*
'* Function: WriteMOMEvent()
'*
'* Purpose: Writes events to MOM EventLog
'*
'***********************************************************************

Function WriteMOMEvent(EventMessage, EventType, EventNumber)

Dim objEvt
Set objEvt = ScriptContext.CreateEvent

objEvt.Message = EventMessage
objEvt.EventType = EventType
objEvt.EventNumber = EventNumber
ScriptContext.Submit(objEvt)

set objEvt = Nothing

End Function



'********************************************************************
'*
'* Function: RetrieveRegValue
'*
'* Purpose: Retrieves String Value from Registry
'*
'********************************************************************

Function RetrieveRegValue (Key, strValueName, intValueType)

' intValueType -&gt; 1 = String Value
' -&gt; 2 = DWORD Value

const HKEY_LOCAL_MACHINE = &amp;H80000002
Dim strServerName
Dim objReg
Dim strRegValue


On Error Resume Next
Err.Clear
Set objReg=GetObject("winmgmts:\root\default:StdRegProv")
If Err.Number &lt;&gt; 0 Then
Err.Clear
strRegValue = NULL
Else

Select Case intValueType
Case 1
strErr = objReg.GetStringValue (HKEY_LOCAL_MACHINE, Key, strValueName, strRegValue)

Case 2
strErr = objReg.GetDWORDValue (HKEY_LOCAL_MACHINE, Key, strValueName, strRegValue)

End Select

' if reading the registry fails via wmi return error

If strErr &lt;&gt; 0 then
strRegValue = NULL
End If
End If

Set objReg = Nothing

RetrieveRegValue = strRegValue

End Function
</Script></Body>
<Language>VBScript</Language>
<Name>Forefront SP Log Realtime Scan Num</Name>
<Parameters>
<Parameter>
<Name>Caller</Name>
<Value>$Config/Parameters/Caller$</Value>
</Parameter>
<Parameter>
<Name>TextLog</Name>
<Value>$Config/Parameters/TextLog$</Value>
</Parameter>
</Parameters>
<ManagementPackId>[Microsoft.ForeFront.SharePoint,,1.0.0.1]</ManagementPackId>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RunScriptAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>SystemLibrary!System.BaseData</InputType>
</WriteActionModuleType>