find a string in a lot of different xml nodes

Welcome Forums General PowerShell Q&A find a string in a lot of different xml nodes

Viewing 2 reply threads
  • Author
    Posts
    • #185474
      Participant
      Topics: 28
      Replies: 59
      Points: 154
      Rank: Participant

      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:

      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.

    • #185486
      Senior Moderator
      Topics: 8
      Replies: 1141
      Points: 3,927
      Helping Hand
      Rank: Community Hero

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

      $MPFile = "\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

    • #185513
      Participant
      Topics: 28
      Replies: 59
      Points: 154
      Rank: Participant

      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.

Viewing 2 reply threads
  • You must be logged in to reply to this topic.