Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert (UIPageSet)

Element properties:

Type DefinitionCommunity.PowerShellMonitoring.Template.PowerShellRule.Alert

Source Code:

<UIPageSet ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert" TypeDefinitionID="Community.PowerShellMonitoring.Template.PowerShellRule.Alert">
<UIPageReferences>
<UIPageReference ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert.General" PageID="MSR!Microsoft.SystemCenter.RuleTemplates.RuleGeneralPage" Usage="CreationOnly">
<InputParameters/>
<InputTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="Category">
<xsl:copy>Alert</xsl:copy>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</InputTransform>
</UIPageReference>
<UIPageReference ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert.Schedule" PageID="System!System.SimpleSchedulerPage" Usage="CreationOnly">
<InputTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="SimpleReccuringSchedule">
<xsl:element name="Interval"><xsl:attribute name="Unit">Minutes</xsl:attribute>15
</xsl:element>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</InputTransform>
</UIPageReference>
<UIPageReference ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert.Script" PageID="Windows!Microsoft.Windows.ScriptPage" Usage="CreationOnly">
<InputParameters>
<ScriptName>MyScript.ps1</ScriptName>
<ScriptBody><Script># Any Arguments specified will be sent to the script as a single string.
# If you need to send multiple values, delimit them with a space, semicolon or other seperator and then use split.
param([string]$Arguments)

$ScomAPI = New-Object -comObject "MOM.ScriptAPI"
$PropertyBag = $ScomAPI.CreatePropertyBag()

# Example of use below, in this case return the length of the string passed in and we'll alert based on that.
# Since the alert comparison is string based in this template we'll need to create a result value and return it.
# Ensure you return a result even if an alert shouldn't be triggered, or the expression filter will error and the module will be unloaded.

$PropertyBag.AddValue("MessageText",$Arguments)
$PropertyBag.AddValue("Length",$Arguments.length)

if($Arguments.length -gt 10) {
$PropertyBag.AddValue("Result","OverThreshold")
}
else
{
$PropertyBag.AddValue("Result","UnderThreshold")
}

# Send output to SCOM
$PropertyBag</Script></ScriptBody>
</InputParameters>
<InputTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:copy-of select="/ScriptName"/>
<xsl:copy-of select="/Arguments"/>
<xsl:copy-of select="/ScriptBody"/>
<xsl:copy-of select="/TimeOutSeconds"/>
</xsl:template>
</xsl:stylesheet>
</InputTransform>
</UIPageReference>
<UIPageReference ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert.AlertExpression" PageID="System!System.ExpressionBuilderPage" Usage="CreationOnly">
<InputParameters>
<DataType>System!System.PropertyBagData</DataType>
</InputParameters>
<InputTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:choose>
<xsl:when test="count(/AlertExpression) &gt; 0">
<xsl:element name="Expression">
<xsl:copy-of select="/AlertExpression"/>
</xsl:element>
</xsl:when>
<xsl:otherwise>
<xsl:element name="Expression">
<xsl:element name="SimpleExpression">
<xsl:element name="ValueExpression">
<xsl:element name="XPathQuery">Property[@Name='Result']</xsl:element>
</xsl:element>
<xsl:element name="Operator">Equal</xsl:element>
<xsl:element name="ValueExpression">
<xsl:element name="Value">OverThreshold</xsl:element>
</xsl:element>
</xsl:element>
</xsl:element>
</xsl:otherwise>
</xsl:choose>
</xsl:template>
</xsl:stylesheet>
</InputTransform>
<Title ID="Title"/>
<TabName ID="TabName"/>
</UIPageReference>
<UIPageReference ID="Community.PowerShellMonitoring.PageSet.Template.PowerShellAlert.AlertConfig" PageID="Health!System.Health.GenerateAlertModuleConfigPage" Usage="CreationOnly">
<InputParameters>
<DataType>System.PropertyBagData</DataType>
</InputParameters>
<InputTransform/>
</UIPageReference>
</UIPageReferences>
<OutputTransform>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0">
<xsl:output method="xml" indent="yes" omit-xml-declaration="yes"/>
<xsl:template match="/">
<xsl:element name="Configuration">
<xsl:copy-of select="/ID"/>
<xsl:copy-of select="/Name"/>
<xsl:copy-of select="/Enabled"/>
<xsl:copy-of select="/Description"/>
<xsl:copy-of select="/Target"/>
<xsl:copy-of select="/Category"/>
<xsl:copy-of select="/LocaleId"/>
<xsl:element name="IntervalSeconds">
<xsl:variable name="RawInterval" select="/SimpleReccuringSchedule/Interval"/>
<xsl:variable name="Units" select="/SimpleReccuringSchedule/Interval/@Unit"/>
<xsl:choose>
<xsl:when test="not(boolean($Units)) or $Units='Seconds'">
<xsl:value-of select="$RawInterval"/>
</xsl:when>
<xsl:when test="$Units='Minutes'">
<xsl:value-of select="$RawInterval*60"/>
</xsl:when>
<xsl:when test="$Units='Hours'">
<xsl:value-of select="$RawInterval*3600"/>
</xsl:when>
<xsl:when test="$Units='Days'">
<xsl:value-of select="$RawInterval*86400"/>
</xsl:when>
</xsl:choose>
</xsl:element>
<xsl:element name="SyncTime">
<xsl:value-of select="/SimpleReccuringSchedule/SyncTime"/>
</xsl:element>
<xsl:element name="ScriptName">
<xsl:value-of select="/ScriptName[1]"/>
</xsl:element>
<xsl:element name="Arguments">
<xsl:value-of select="/Arguments[1]"/>
</xsl:element>
<xsl:element name="ScriptBody">
<xsl:value-of select="/ScriptBody[1]"/>
</xsl:element>
<xsl:element name="TimeoutSeconds">
<xsl:value-of select="/TimeoutSeconds[1]"/>
</xsl:element>
<xsl:element name="AlertExpression">
<xsl:copy-of select="/Expression[1]/*"/>
</xsl:element>
<xsl:copy-of select="/Priority"/>
<xsl:copy-of select="/Severity"/>
<xsl:copy-of select="/AlertName"/>
<xsl:copy-of select="/AlertDescription"/>
<xsl:copy-of select="/AlertOwner"/>
<xsl:copy-of select="/AlertParameters"/>
<xsl:copy-of select="/Suppression"/>
<xsl:copy-of select="/Custom1"/>
<xsl:copy-of select="/Custom2"/>
<xsl:copy-of select="/Custom3"/>
<xsl:copy-of select="/Custom4"/>
<xsl:copy-of select="/Custom5"/>
<xsl:copy-of select="/Custom6"/>
<xsl:copy-of select="/Custom7"/>
<xsl:copy-of select="/Custom8"/>
<xsl:copy-of select="/Custom9"/>
<xsl:copy-of select="/Custom10"/>
</xsl:element>
</xsl:template>
</xsl:stylesheet>
</OutputTransform>
</UIPageSet>