SCOM.Management.ExportEventLog.WA (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.BaseData

Member Modules:

ID Module Type TypeId RunAs 
PSWA WriteAction Microsoft.Windows.PowerShellWriteAction Default

Overrideable Parameters:

IDParameterTypeSelector
LogNamestring$Config/LogName$
SharePathstring$Config/SharePath$
TimeoutSecondsint$Config/TimeoutSeconds$

Source Code:

<WriteActionModuleType ID="SCOM.Management.ExportEventLog.WA" Accessibility="Internal" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="LogName" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="SharePath" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="LogName" Selector="$Config/LogName$" ParameterType="string"/>
<OverrideableParameter ID="SharePath" Selector="$Config/SharePath$" ParameterType="string"/>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="PSWA" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>SCOM.Management.ExportEventLog.WA.ps1</ScriptName>
<ScriptBody><Script>
#=================================================================================
# Script to Export Event log to a Share via PowerShell
#=================================================================================
param($LogName,$SharePath)

# For testing discovery manually in PowerShell:
# $LogName = "Operations Manager"
# $SharePath = "\\server\logbackup"

#=================================================================================
# Constants section - modify stuff here:

# Assign script name variable for use in event logging
$ScriptName = "SCOM.Management.ExportEventLog.WA.ps1"
#=================================================================================

# Gather script start time
$StartTime = Get-Date

# Gather who the script is running as
$whoami = whoami

#Load the MOMScript API and discovery propertybag
$momapi = New-Object -comObject "Mom.ScriptAPI"

#Log script event that we are starting task
$momapi.LogScriptEvent($ScriptName,1319,0, "Starting script. Running as ($whoami)")

# Begin Main Script
#=================================================================================
$ComputerName = $env:computername

$TimeStamp = Get-Date -Format "MM-dd-yyyy"
wevtutil epl $LogName "$SharePath\$ComputerName $LogName $TimeStamp.evtx" /overwrite:true

# Log an event for script ending and total execution time.
$EndTime = Get-Date
$ScriptTime = ($EndTime - $StartTime).TotalSeconds
$momapi.LogScriptEvent($ScriptName,1319,0,"`n Script has completed. `n Runtime was ($ScriptTime) seconds.")
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>LogName</Name>
<Value>$Config/LogName$</Value>
</Parameter>
<Parameter>
<Name>SharePath</Name>
<Value>$Config/SharePath$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="PSWA"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.BaseData</OutputType>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>