The combination of the search string "//config/exceptions/exception[@enabled='true']/ManagementPack[@Name='$mpName']/AlertProperty/ancestor::exception" and the alert match Where-Object -FilterScript { $newAlert.($_.Alert.AlertProperty) -match "$($_.Alert.AlertPropertyMatches)" } will not work. The ManagementPack element is not supposed to have an Alert child, so this will always fail.
The combination of the search string
"//config/exceptions/exception[@enabled='true']/ManagementPack[@Name='$mpName']/AlertProperty/ancestor::exception"
and the alert matchWhere-Object -FilterScript { $newAlert.($_.Alert.AlertProperty) -match "$($_.Alert.AlertPropertyMatches)" }
will not work. TheManagementPack
element is not supposed to have anAlert
child, so this will always fail.