hmscott4 / AlertManagement

Manage SCOM Alerts
2 stars 3 forks source link

Assign-ScomAlert: Single-Quote causes XPath to fail #11

Closed hmscott4 closed 3 years ago

hmscott4 commented 3 years ago

When the Name of an alert contains a single quote ('), the Assign-Alert script fails. Resolve by double-quoting Alert Name variable in PS.

randomnote1 commented 3 years ago

@hmscott4, are you talking about changing this:

    $searchStrings = @(
        "//config/exceptions/exception[AlertName='$alertName' and @enabled='true']"
        "//config/rules/rule[managementPackName='$mpName' and @enabled='true']"
    )

to this? (two single quotes)

    $searchStrings = @(
        "//config/exceptions/exception[AlertName=''$alertName'' and @enabled='true']"
        "//config/rules/rule[managementPackName=''$mpName'' and @enabled='true']"
    )