Cisco.Ucs.UpdateAlert.WriteActionModuleType (WriteActionModuleType)

Element properties:

TypeWriteActionModuleType
IsolationAny
AccessibilityPublic
RunAsDefault
InputTypeSystem.BaseData

Member Modules:

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

Overrideable Parameters:

IDParameterTypeSelector
TimeoutSecondsint$Config/TimeoutSeconds$
Loggingstring$Config/Loging$

Source Code:

<WriteActionModuleType ID="Cisco.Ucs.UpdateAlert.WriteActionModuleType" Accessibility="Public" Batching="false">
<Configuration>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TimeoutSeconds" type="xsd:integer"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Loging" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="TypeId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Dn" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="FaultCode" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="FaultId" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Ack" type="xsd:string"/>
<xsd:element xmlns:xsd="http://www.w3.org/2001/XMLSchema" minOccurs="1" name="Occur" type="xsd:string"/>
</Configuration>
<OverrideableParameters>
<OverrideableParameter ID="TimeoutSeconds" Selector="$Config/TimeoutSeconds$" ParameterType="int"/>
<OverrideableParameter ID="Logging" Selector="$Config/Loging$" ParameterType="string"/>
</OverrideableParameters>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<WriteAction ID="PowerShellWriteAction" TypeID="Windows!Microsoft.Windows.PowerShellWriteAction">
<ScriptName>Cisco.Ucs.UpdateAlert.WriteAction.ps1</ScriptName>
<ScriptBody><Script>Param (
$Loging,
$TypeId,
$Dn,
$FaultCode,
$FaultId,
$Ack,
$Occur
)

######
# Declaring Constants
######
########################################################################################
Set-Variable -Name cCODE -Value "19900"
Set-Variable -Name cLOGINGCODE -Value "19901"

Set-Variable -Name cERROR -Value "1"
Set-Variable -Name cWARNING -Value "2"
Set-Variable -Name cINFORMATION -Value "4"

Set-Variable -Name cSERVICENAME -Value "CiscoUcsMonitoringService"

Set-Variable -Name cSCRIPTNAME -Value "Cisco.Ucs.UpdateAlert.WriteAction.ps1"
########################################################################################

#Referring MOM API
$oScriptAPI = New-Object -ComObject 'MOM.ScriptAPI'

#Creating Logs
Function LogEvent ($sMessage, $iEventType, $iErrorEventId)
{
$oScriptAPI.LogScriptEvent("Cisco Management Pack [" + $cSCRIPTNAME + "]", $iErrorEventId, $iEventType, $sMessage)
}

######
# Main Method
######
Function Main
{
Import-Module OperationsManager

if($Loging -eq "true")
{
LogEvent "Starting to Update Alert with TypeId: ($TypeId) DN :($Dn) FaultCode: ($FaultCode) Fault Id: ($FaultId) Ack: ($Ack) Occur: ($Occur)" $cINFORMATION $cCODE
}

#$scomActiveAlert = Get-SCOMAlert | Where-Object {$_.MonitoringObjectFullName.Contains("$TypeId") -and $_.CustomField10 -eq "$Dn" -and $_.CustomField4 -eq "$FaultCode" -and $_.CustomField6 -eq "$FaultId"}
$scomActiveAlert = Get-SCOMAlert | Where-Object {$_.CustomField1 -eq "$TypeId" -and $_.CustomField10 -eq "$Dn" -and $_.CustomField4 -eq "$FaultCode" -and $_.CustomField6 -eq "$FaultId"}



if($scomActiveAlert -ne $null)
{
$scomActiveAlert | Set-SCOMAlert -ResolutionState 0 -CustomField2 "$Ack" -CustomField3 "$Occur"
if($Loging -eq "true")
{
LogEvent "Updated Alert for UCS TypeId: ($TypeId), Dn:($Dn), Fault Code:($FaultCode), Fault Id:($FaultId) with Value Ack:($Ack) and Occur:($Occur)" $cINFORMATION $cCODE
}
}


}

Main
</Script></ScriptBody>
<Parameters>
<Parameter>
<Name>Loging</Name>
<Value>$Config/Loging$</Value>
</Parameter>
<Parameter>
<Name>TypeId</Name>
<Value>$Config/TypeId$</Value>
</Parameter>
<Parameter>
<Name>Dn</Name>
<Value>$Config/Dn$</Value>
</Parameter>
<Parameter>
<Name>FaultCode</Name>
<Value>$Config/FaultCode$</Value>
</Parameter>
<Parameter>
<Name>FaultId</Name>
<Value>$Config/FaultId$</Value>
</Parameter>
<Parameter>
<Name>Ack</Name>
<Value>$Config/Ack$</Value>
</Parameter>
<Parameter>
<Name>Occur</Name>
<Value>$Config/Occur$</Value>
</Parameter>
</Parameters>
<TimeoutSeconds>$Config/TimeoutSeconds$</TimeoutSeconds>
</WriteAction>
</MemberModules>
<Composition>
<Node ID="PowerShellWriteAction"/>
</Composition>
</Composite>
</ModuleImplementation>
<InputType>System!System.BaseData</InputType>
</WriteActionModuleType>