Restart Microsoft Audit Collection Services Forwarder

Microsoft.SystemCenter.ACS.RestartACSForwarderAction (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsSystem.PrivilegedMonitoringAccount
InputTypeSystem.BaseData
OutputTypeSystem.PropertyBagData

Member Modules:

ID Module Type TypeId RunAs 
RestartACSForwarder WriteAction Microsoft.Windows.PowerShellPropertyBagWriteAction Default

Source Code:

<WriteActionModuleType ID="Microsoft.SystemCenter.ACS.RestartACSForwarderAction" Accessibility="Internal" RunAs="System!System.PrivilegedMonitoringAccount" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>Windows!Microsoft.Windows.WindowsEventLogEventTypeSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element name="EventId" type="xsd:integer"/>
<xsd:element name="EventType" type="WindowsEventLogEventType"/>
<xsd:element name="RestartReason" type="xsd:string"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="RestartACSForwarder" TypeID="Windows!Microsoft.Windows.PowerShellPropertyBagWriteAction">
<ScriptName>RestartACSForwarder.ps1</ScriptName>
<ScriptBody><Script>

param($EventId, $EVentType, $RestartReason)

$oAPI = new-object -comObject "MOM.ScriptAPI"
$oBag = $oAPI.CreatePropertyBag()

$SCRIPT_NAME = "RestartACSForwarder.ps1";
$ENU_MESSAGE_BASE = "Restarting Audit Collection Services Forwarder. ";

$SW_HIDE = 0;
$CREATE_BREAKAWAY_FROM_JOB = 0x1000000;

# Process Arguments:
# 0 - EventId
# 1 - EventType
# 2 - RestartReason

$EVENTLOG_SUCCESS = 0x0000; # Information event
$EVENTLOG_AUDIT_FAILURE = 0x0010; # Failure Audit event
$EVENTLOG_AUDIT_SUCCESS = 0x0008; # Success Audit event
$EVENTLOG_ERROR_TYPE = 0x0001; # Error event
$EVENTLOG_INFORMATION_TYPE = 0x0004; # Information event
$EVENTLOG_WARNING_TYPE = 0x0002; # Warning event

switch($EventType)
{
"Success" { $EventType = $EVENTLOG_SUCCESS }
"AuditFailure" { $EventType = $EVENTLOG_AUDIT_FAILURE }
"AuditSuccess" { $EventType = $EVENTLOG_AUDIT_SUCCESS }
"Error" { $EventType = $EVENTLOG_ERROR_TYPE }
"Information" {$EventType = $EVENTLOG_INFORMATION_TYPE }
"Warning" { $EventType = $EVENTLOG_WARNING_TYPE }
}

$RestartReason = $ENU_MESSAGE_BASE + $RestartReason;

$oAPI.LogScriptEvent($SCRIPT_NAME, $EventId, $EventType, $RestartReason)
$oBag.AddValue($SCRIPT_NAME, $RestartReason)
$oBag

$strCommand = [System.Environment]::ExpandEnvironmentVariables("%ComSpec% /c net stop adtagent &amp; net start adtagent &amp; net start adtagent &amp; net start adtagent &amp; net start adtagent");

// Configure the process to break away from the job
$objConfig=[wmiclass]"Win32_ProcessStartup"
$objConfig.Properties['ShowWindow'].value=$False
([wmiclass]"win32_Process").create($strCommand, $null ,$objConfig, $intProcessID)

</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>EventId</Name>
<Value>$Config/EventId$</Value>
</Parameter>
<Parameter>
<Name>EVentType</Name>
<Value>$Config/EventType$</Value>
</Parameter>
<Parameter>
<Name>RestartReason</Name>
<Value>$Config/RestartReason$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>300</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="RestartACSForwarder"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.PropertyBagData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>