find a string in a lot of different xml nodes

i have a scom custom management pack. i have the xml loaded as $xml. the text “Microsoft.Windows.Server.2003” appears in the xml around 100 times. it can appear as “id”, it can appear as “context,” it can appear in “target”. the node names are all different. here’s a sample:

https://gist.github.com/Curtmcgirt/b2008bae270683589d283f645e5ed143

i want to find all nodes that contain the text “Microsoft.Windows.Server.2003” in any way, shape, form, property, attribute, etc. is that doable? i’ve seen some promising stuff about select-xml, but all the examples seem to be about xml nodes that are identical.

Never tried this, but below example and link might help you which uses SCOM cmdlets.

$MPFile = "<path>\Microsoft.Windows.Server.2003.mp"
Get-SCOMMonitor -ManagementPack $MPFile

https://docs.microsoft.com/en-us/powershell/module/operationsmanager/get-scommonitor?view=systemcenter-ps-2019#examples

thank you, but no, i need the actual xml nodes so i can then delete them from the xml file. so far i’m doing this, but i’m hoping there’s a more efficient way to just locate every node that contains $mp, in case i run into some xml where i don’t know the exact path and property of every node.

<script src=“https://gist.github.com/Curtmcgirt/4e50193e8c715e46c1e926bbcc645a4b.js”></script>