hmscott4 / AlertManagement

Manage SCOM Alerts
2 stars 3 forks source link

Alert Assignment Property requires escaping characters #40

Closed hmscott4 closed 3 years ago

hmscott4 commented 3 years ago

Example:

    <exception ID="2" Name="Server Offline" Owner="EFG Windows Team" enabled="true">
      <Alert Name="Failed to Connect to Computer" >
        <AlertProperty>MonitoringObjectDisplayName</AlertProperty>
        <AlertPropertyMatches>efg\.lcl</AlertPropertyMatches>
      </Alert>

in this example, the period in efg.lcl requires escaping with "\". Can we remove this requirement and make it more natural for the admin?

randomnote1 commented 3 years ago

The escaping of the dot . is required because the script uses regular expressions (regex). Regex is faster and more powerful than comparison operators in PowerShell. However, I do agree it's not intuitive. Maybe we could implement expression options like what SCOM does.

Operator Description
MatchesWildcard The expression evaluates as true if it matches the specified wildcard expression. The following wildcard characters are allowed:
  • # — represents a number [0–9].
  • ? — represents any single character.
  • * — represents any sequence of characters.
  • \ — escapes the following character; for example, # is used to specify the # character.
ContainsSubstring Expression evaluates as true if it contains the substring specified in the pattern. The pattern is mapped to a regular expression, such as "^.EscapedPattern.$".
MatchesRegularExpression The expression evaluates as true if it matches the specified regular expression pattern. The regular expression evaluation uses the ATL regular expression engine.
DoesNotContainSubstring The expression evaluates as true if it does not contain the substring specified in the pattern.
DoesNotMatchWildcard The expression evaluates as true if it does not match the specified wildcard pattern.
DoesNotMatchRegularExpression The expression evaluates as true if it does not match the specified regular expression pattern.
hmscott4 commented 3 years ago

Closing this issue out for now. Testing showed that efg.lcl worked just the same as efg.lcl.