Microsoft.Windows.ScriptWriteAction

Applies To: Operations Manager 2007 R2

The Microsoft.Windows.ScriptWriteAction write action module type is used to run a script that alters the system in some way. The module type accepts System.BaseData data and outputs System.CommandOutput data.

Usage

Use this module when you want to gather data from a script on a monitored computer and alter the system in some way.

Type Definition

<WriteActionModuleType ID="Microsoft.Windows.ScriptWriteAction" Accessibility="Public" Batching="false">
  <Configuration>
    <IncludeSchemaTypes>
      <SchemaType>System!System.ParamListSchema</SchemaType>
      <SchemaType>System!System.CommandExecuterSchema</SchemaType>
    </IncludeSchemaTypes>
    <xsd:element name="ScriptName" type="xsd:string" />
    <xsd:element name="Arguments" type="xsd:string" />
    <xsd:element name="ScriptBody" type="xsd:string" />
    <xsd:element name="SecureInput" minOccurs="0" maxOccurs="1">
      <xsd:simpleType>
        <xsd:restriction base="xsd:string">
          <xsd:maxLength value="256" />
        </xsd:restriction>
      </xsd:simpleType>
    </xsd:element>
    <xsd:element name="TimeoutSeconds" type="xsd:integer" />
    <xsd:element minOccurs="0" maxOccurs="1" name="EventPolicy" type="CommandExecuterEventPolicyType" />
  </Configuration>
  <OverrideableParameters>
    <OverrideableParameter ID="Arguments" Selector="$Config/Arguments$" ParameterType="string" />
    <OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int" />
  </OverrideableParameters>
  <ModuleImplementation Isolation="Any">
    <Composite>
      <MemberModules>
        <WriteAction ID="WA1" TypeID="System!System.CommandExecuter">
          <ApplicationName><![CDATA[%windir%\system32\cscript.exe]]></ApplicationName>
          <WorkingDirectory />
          <CommandLine>/nologo "$Config/ScriptName$" $Config/Arguments$</CommandLine>
          <SecureInput>$Config/SecureInput$</SecureInput>
          <TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
          <RequireOutput>true</RequireOutput>
          <Files>
            <File>
              <Name>$Config/ScriptName$</Name>
              <Contents>$Config/ScriptBody$</Contents>
              <Unicode>true</Unicode>
            </File>
          </Files>
          <DefaultEventPolicy>
            <StdOutMatches />
            <StdErrMatches>\a+</StdErrMatches>
            <ExitCodeMatches>[^0]+</ExitCodeMatches>
          </DefaultEventPolicy>
          <EventPolicy>$Config/EventPolicy$</EventPolicy>
        </WriteAction>
      </MemberModules>
      <Composition>
        <Node ID="WA1" />
      </Composition>
    </Composite>
  </ModuleImplementation>
  <OutputType>System!System.CommandOutput</OutputType>
  <InputType>System!System.BaseData</InputType>
</WriteActionModuleType>

Parameters

The Microsoft.Windows.ScriptWriteAction module supports the configuration parameters described in the following table.

Parameter Type Overrideable Description

ScriptName

String

False

Required parameter. Contains the file name of the script (including the extension) that identifies the script type.

Arguments

String

True

Required parameter. Contains the arguments to be supplied to the script on execution.

ScriptBody

String

False

Required parameter. Contains the script contents. If the script contains XML characters that must be escaped, it is recommended that the entire script be wrapped in a CDATA element.

SecureInput

String

False

Optional parameter. Contains the data to be passed to the script in a secure method. This is used to provide passwords to the script to be used during execution. Maximum length of the string is 256 characters.

TimeoutSeconds

Integer

True

Required parameter. Specifies the time the script is allowed to run before being closed by the module and marked as failed.

EventPolicy

CommandExecuterEventPolicyType

False

Optional parameter. Defines the expected output and the behavior based on unexpected output from the script

For more information about all parameters of this module, see Microsoft.Windows.ScriptProbeAction.

Composition

The Microsoft.Windows.ScriptWriteAction module is a composite module that contains the member module described in the following table.

Workflow Run Order Module Type Usage

1

System.CommandExecuter

Runs the specified script.

Module Type

Usage

Microsoft.Windows.ScriptDiscoveryProbe

Used for discovery scripts that are triggered by data sources other than the simple scheduler.

Microsoft.Windows.ScriptProbeAction

Used for scripts that are triggered by data sources other than the simple scheduler.

Microsoft.Windows.ScriptPropertyBagProbe

Used for monitoring scripts that are triggered by data sources other than the simple scheduler.

Microsoft.Windows.TimedScript.DiscoveryProvider

Used for scheduled discovery scripts that are triggered by the simple scheduler.

Microsoft.Windows.TimedScript.EventProvider

Used for scheduled scripts that output data that is mapped to an event and stored in the Operations Manager databases.

Microsoft.Windows.TimedScript.PropertyBagProvider

Used for scheduled scripts that are used in rule or monitor workflows. This module type provides property bag output that is better suited for XPath referencing and expression evaluation. This module is triggered by the simple scheduler.

External Module References

None.

Remarks

For remarks, see Microsoft.Windows.ScriptProbeAction.

Sample

The following XML sample provides a task that uses the Microsoft.Windows.ScriptWriteAction module to stop an IIS 2003 application pool.

<Task ID="Microsoft.Windows.InternetInformationServices.2003.ApplicationPool.StopApplicationPool.Task" Accessibility="Public" Enabled="true" Target="Microsoft.Windows.InternetInformationServices.2003.ApplicationPool" Remotable="true">
  <Category>Maintenance</Category>
  <WriteAction ID="WA" TypeID="Windows!Microsoft.Windows.ScriptWriteAction">
    <ScriptName>WebSiteDiagnostics.vbs</ScriptName>
    <Arguments>$Target/Property[Type="IISCommon!Microsoft.Windows.InternetInformationServices.ApplicationPool"]/PoolID$</Arguments>
    <ScriptBody>
      Call Main

      Sub Main()
        Dim AppPool
        Dim StartFlag
        Dim oArgs
        
        Set oArgs = WScript.Arguments
        
        if oArgs.Count &lt;&gt; 2 Then
          WScript.Quit
        End If

        AppPool = oArgs(1)
        StopApplicationPool(AppPool)
   
     
      End Sub

      Sub StartApplicationPool(pool)
      ...
      End Sub

      Sub StopApplicationPool(pool)
      ...
      End Sub


    </ScriptBody>
    <TimeoutSeconds>300</TimeoutSeconds>
  </WriteAction>
</Task>

Information

   

Module Type

WriteActionModuleType

Input Type

System.BaseData

Output Type

System.CommandOutput

Implementation

Composite

Library

Microsoft.Windows.Library